![](/img/trans.png)
[英]Show tooltip arrow at top of icon which is align end of text in TextView
[英]Align button top to textview end
但是,这可能是一个愚蠢的愚蠢问题,已经使我疯狂。
人们将如何进行这种调整?
我将使用哪种布局? 如何将这些元素的宽度设置为某种百分比?
用这个:
<?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" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="bsdvdsjvbdsjfvcbdsvjdsbvbcvm vm,cxvmjbvjcbvjxvbxncvcxvxcbzbdfgdfzzgdfgdfgdfzgdfzvgzxvbnxcjkdsbvckjdsvbchsvgdhjsdvbndsbchjsdfgdshfgdshcb nsxbc" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="bottom"
android:text="CheckBox" />
</LinearLayout>
尝试这个..
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="top"
android:gravity="top"
android:text="yourtext" />
<ImageView
android:id="@+id/img_icon"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="bottom"
android:src="@drawable/yourimageview" />
</LinearLayout>
将您的textview和复选框在html中水平对齐。 设置复选框的android:gravity ='bottom'属性。 要设置宽度,请使用android:gravity属性。 您用于重力的数字并不重要; 大小将根据您正在使用的视图内的重力总数进行设置。 如果文本是重力5,复选框是重力1,则文本将填充视图的84%,而cb将填充到视图的16%。 使用50和10也会发生相同的情况。总数为100%。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.