Android Weight Not Working

走远了吗. 提交于 2019-12-13 21:37:03

问题


I have a textview and edittext in a linear layout. Neither view shows up at all if done the way I've seen every example of using weight to set width as a percentage of parent that I can find.

<?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">
<TextView
  android:id="@+id/custLabel"
  android:layout_height="wrap_content"
  android:layout_weight=".35"
  android:layout_width="0dip"  
  android:text="Name"/>
<EditText
  android:id="@+id/customer"
  android:layout_height="wrap_content"
  android:layout_weight=".65"
  android:layout_width="0dip"/>
</LinearLayout>

回答1:


Change the orientation of the Layout. You have it vertical and put things there, weighting width!



来源:https://stackoverflow.com/questions/9135827/android-weight-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!