0

I have the xml code shown below. Everything is working as it should except the final textView( id locationTextView) which won't stay right. I want it to stay as right as possible, but I can't do that(it still appears straight after the linear Layout).Should I set a left margin?. And for the textView1 how can I make it to show only a certain part of the whole text, because I have texts of different lengths and they ruin the layout.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@color/product_list_item_bg"
    android:descendantFocusability="blocksDescendants">

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

        <ImageView
            android:id="@+id/icon"
            android:layout_width="72dip"
            android:layout_height="72dip"
            android:layout_margin="3dip"
            android:adjustViewBounds="true"
            android:contentDescription="@string/descr_image"
            android:scaleType="centerCrop" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:id="@+id/item"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="5dp"
                android:padding="2dp"
                android:text="Medium Text"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="#33CC33" />

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:text="TextView" />

        </LinearLayout>
        <TextView
            android:gravity="right"
            android:layout_width="72dip"
            android:layout_height="72dip"
            android:layout_marginTop="0dp"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/locationTextView"
            android:layout_gravity="right" />
    </LinearLayout>
</RelativeLayout>
Bogdan Daniel
  • 2,689
  • 11
  • 43
  • 76

1 Answers1

1

Try android:layout_weight="1" or some other value for your locationTextView. You can also try out android:weightSum="3" (or that is appropriate instead of 3) on your root LinearLayout. Assign proper weights to your different child views. You can get help here

For showing text in a presentable way, you could use android:ellipsize="marquee" or other options available.

Community
  • 1
  • 1
Mithun
  • 2,075
  • 3
  • 19
  • 26