-4

enter image description here

Here in this layout I want first imageView then textView and then once I complete the textView immediately I want to add imageView, How do I do this.

Vinod Pattanshetti
  • 2,465
  • 3
  • 22
  • 36
  • I have tried with custom FlowLayout but it's taking all above three views in vetical orientation manner How do I do this horizontal manner. – Vinod Pattanshetti Dec 13 '17 at 06:43

3 Answers3

1

Try this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/img"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher_round" />

    <TextView
        android:id="@+id/MyTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toEndOf="@id/img"
        android:gravity="center"
        android:text="NILU" />   


</RelativeLayout>

Than set Imageview at the end of textview using ImageSpan lIke below code

 textView = (TextView) findViewById(R.id.MyTextView);
 Spannable span = new SpannableString("nilu  ");
 Drawable demo = getResources().getDrawable(R.mipmap.ic_launcher);
 demo.setBounds(0, 0, 50, 50);
 ImageSpan image = new ImageSpan(demo, ImageSpan.ALIGN_BASELINE);
 span.setSpan(image,span.length()-1,span.length(),Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
 textView.setText(span);

OUTPUT enter image description here

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
0

Use this

 android:drawableRight="R.drawabal/xyz"
mehul chauhan
  • 1,792
  • 11
  • 26
  • Please at least at a little bit of explanation why this is the answer to the question, in the current state this is a very low quality answer. – Rolf ツ Dec 13 '17 at 10:50
0

Just add this into your layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.android.stackoverflow.MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:text="This is your sample text where you can add any 
     description" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher" />
</LinearLayout>

Nikhil Lotke
  • 605
  • 7
  • 15