简体   繁体   中英

Android ImageView and Textview

在此处输入图片说明

I want to create layout like at picture but i don't have clue at all how to make like that.. Does anyone can give me a clue or alternative how to do that ?

Split it like this. Imageview and first textview in a linearlayout Horizontal. and then this linearlayout Horizontal and second textview in a linear layout vertical.

已编辑

One way to do this could be to lay the TextView and then overlay the ImageView on it. I think a RelativeLayout with the TextView defined first and followed by the ImageView might do the trick. You can toggle the visibility of the ImageView but would need to ensure that any text written to the TextView is written after taking into account width of the ImageView so as to not obscure any text.

You can try adding two textviews in a relative layout and in addition to that an imageview. This might help you to get started.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/item_generator"
    android:background="#FF000000">

    <TextView
        android:id="@+id/item_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:textColor="#FFF"
        android:textSize="18sp" />

    <TextView
        android:id="@+id/item_title_val"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_marginRight="20dp"
        android:layout_marginTop="16dp"        
        android:textColor="@color/blue"
        android:textSize="16sp" />

    <TextView
        android:id="@+id/item_subtitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/item_title"
        android:layout_below="@+id/item_title"
        android:textColor="#888"
        android:textSize="14sp" />

    <ImageView
        android:id="@+id/item_right_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginTop="10dp"
        android:layout_marginRight="40dp"
        android:padding="0dp"
        android:contentDescription="@string/hello_world" />

</RelativeLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM