mardi 26 mai 2015

How to set textView as right as possible and set textView show only a part of text?

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://ift.tt/nIICcg"
    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>

Aucun commentaire:

Enregistrer un commentaire