Fixed Width TextView with Stretched Composition

I am trying to execute the following layout: a fixed width of a TextView aligned to the left of the parent, with text inside it aligned to the right side of that TextView (what, why a fixed width, can this be done in another way?), And the rest of the parent is filled with an extensible (simple line ) For instance:screenshot

This is a ListView containing 2 types of lines, and the layout for lines with lines is pretty trivial - LinearLayout with TextView and ImageView (I can post the exact code later if necessary). And I get a warning that it can be replaced with a single TextView with a composite drawing.

, . , - TextView, ListItem, .

- ?

: -, , ( , , , ) , , - , TextView ImageView.

+5
6

, - . TextView , , , . .

+3

, , , . , , , , textview . , , , , , . , , , .

+3

, TextView. , TextView, layoutWidth Parent . . .

+1

, , , , , :

    <RelativeLayout
        android:id="@+id/relTrial"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    <TextView 
        android:id="@+id/txtTime"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:gravity="right"
        android:text="12:45 AM"
        android:layout_alignParentLeft="true"/>
    <LinearLayout 
        android:id="@+id/lnrSep"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:gravity="bottom"
        android:layout_marginLeft="5dp"  
        android:layout_marginRight="5dp"          
        android:layout_centerVertical="true"
        android:orientation="horizontal"
        android:background="@android:color/darker_gray"
        android:layout_toRightOf="@+id/txtTime"
        android:layout_alignParentRight="true"></LinearLayout>
    </RelativeLayout>

, , , .

, .

0

, ? :

android:drawableBottom="@drawable/line"
0
source

Your view is created from this -

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

    <TextView
        android:id="@+id/time"
        android:layout_width="@dimen/today_time_width"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:gravity="right"
        android:layout_marginRight="5dp" />

    <ImageView
        android:layout_gravity="center"
        android:id="@+id/border"
        android:layout_width="match_parent"
        android:layout_height="@dimen/today_current"
        android:src="?attr/item_boundary" />

</LinearLayout>
0
source

All Articles