![](/img/trans.png)
[英]How can TextView be aligned right next to an ImageButton in LinearLayout
[英]How can TextView be aligned right next to a Buttin in LinearLayout
我试图找到一种解决方案,但我无法做到。 问题很简单,如何在LinearLayout
对齐TextView
和Button。
像这样:
我试过了,但是没有用:
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<EditText
android:layout_width="wrap_content"
android:gravity="center_horizontal"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Name"
android:ems="10"
android:id="@+id/editText"
android:textAppearance="@style/TextAppearance.AppCompat.Light.SearchResult.Subtitle" />
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button" />
</LinearLayout>
提前致谢!
你需要设置
android:orientation="horizontal"
在您的LinearLayout中
尝试这个
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="my edit text"/>
<Button
android:text="Add"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
这将在您的情况下工作 谢谢
沿LinearLayout方向替换
android:orientation="vertical"
至
android:orientation="horizontal"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.