作者a43149 (台湾真是个宝岛... 屁!)
看板AndroidDev
标题[问题] linearlayout的问题
时间Tue May 17 16:15:58 2016
下面是我的layout程式码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="
http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/mybut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:text="@string/button"/>
<TextView
android:id="@+id/mytext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/text"/>
</LinearLayout>
<Button
android:id="@+id/mybut1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:text="@string/button1"/>
<TextView
android:id="@+id/mytext1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="@string/text"/>
</LinearLayout>
我想要让我的textview1显示在我的button1的旁边
可是我这样弄怎麽只有显示出button1而已 其他的都没有出现
有人可以帮我看看吗? 谢谢!!
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 122.146.85.149
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/AndroidDev/M.1463472962.A.E4A.html
※ 编辑: a43149 (122.146.85.149), 05/17/2016 16:16:24
1F:→ LZN: 要不要先说明哪一个是textview1哪一个是button1? 05/17 16:24
2F:→ king5201: 你的layout只会出现mybut跟mytext这两个吧... 05/17 17:26
3F:→ king5201: 调整一下里面LinearLayout layout_height试试? 05/17 17:28
4F:→ FlowerYen: 你采用了 horizontal的linear来包你的textview跟button 05/17 17:44
5F:→ FlowerYen: 为了要实现"textview1显示在我的button1的旁边" 05/17 17:45
6F:→ FlowerYen: 但是你的mytext的width=match_parent 所以mybut消失了 05/17 17:46
7F:→ FlowerYen: 解法:使用layout_weight,或者是relative layout 05/17 17:48