[英]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.