簡體   English   中英

如何在imageview的下方和右側對齊textview?

[英]How to align textview below and right of imageview?

我正在使用一個UI,其中我想將Textview對齊到ImageView的右側以及同一ImageView的下方。 我想要這個是因為,如果我將ImageView的TextView對齊,它會在ImageView下方留下一些空白。

以下是屏幕截圖:

當前情況: https ://drive.google.com/open id = 0B6J8T8u_aeWrWWptZTJqTzVMTkk

要求: https //drive.google.com/open?id = 0B6J8T8u_aeWrbXVnNVJEd0g2dWM

XML:

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


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">


        <com.meg7.widget.RectangleImageView
            android:id="@+id/ivUserProfilePictureWOQ"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:scaleType="centerCrop"
            android:src="@drawable/splash_image" />

        <LinearLayout
            android:id="@+id/ll_woq_quote_name"
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="wrap_content"
            android:layout_toEndOf="@+id/ivUserProfilePictureWOQ">

            <TextView
                android:id="@+id/tv_woq_user_name"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Name"/>

        <TextView
            android:id="@+id/tv_woq_user_quotes"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="Qoute"
            android:textSize="20dp"
            android:textIsSelectable="true" />

        </LinearLayout>


    </RelativeLayout>


    <LinearLayout
        android:id="@+id/ll_woq_tags"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ivUserProfilePictureWOQ"
        android:orientation="vertical">

        <TextView
            android:id="@+id/tv_woq_tags"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textSize="18dp"
            android:padding="5dp"
            android:text="tags" />

        <TextView
            android:id="@+id/tv_woq_likes"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textSize="14dp"
            android:padding="5dp"
            android:text="likes" />

    </LinearLayout>


</LinearLayout>

所以我只是根據需要創建了一個xml ,只需在您的項目中使用它

<?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="match_parent"
    android:orientation="vertical">

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


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

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".2"
                android:gravity="center"
                android:padding="7dp">

                <com.meg7.widget.RectangleImageView
                    android:id="@+id/ivUserProfilePictureWOQ"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/splash_image" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/ll_woq_quote_name"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".8"
                android:orientation="vertical"
                android:padding="5dp"
                android:weightSum="1">

                <TextView
                    android:id="@+id/tv_woq_user_name"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight=".2"
                    android:text="Einstien" />

                <TextView
                    android:id="@+id/tv_woq_user_quotes"
                    android:layout_width="wrap_content"
                    android:layout_height="0dp"
                    android:layout_weight=".8"
                    android:maxLines="2"
                    android:text="This is dummy text and check use this in project , do tell me if its working fine or not ......."
                    android:textIsSelectable="true"
                    android:textSize="16sp" />

            </LinearLayout>


        </LinearLayout>

        <TextView
            android:id="@+id/tv_desciption"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:text="ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample"
            android:textSize="18dp" />

        <LinearLayout
            android:id="@+id/ll_woq_tags"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:id="@+id/tv_woq_tags"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="5dp"
                android:text="tags"
                android:textSize="18dp" />

            <TextView
                android:id="@+id/tv_woq_likes"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="5dp"
                android:text="likes"
                android:textSize="14dp" />

        </LinearLayout>


    </LinearLayout>
</RelativeLayout> 

不要重新發明輪子,如果可以的話,請使用庫: http : //deano2390.github.io/FlowTextView/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM