Android的重量不工作 [英] Android Weight Not Working

查看:128
本文介绍了Android的重量不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个线性布局一个TextView和EditText上。鉴于都不做,如果我见过用重量来设置宽度为母公司的百分比,我可以找到的每个实例的方式都显示出来。

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
  机器人:方向=垂直
  机器人:layout_width =FILL_PARENT
  机器人:layout_height =FILL_PARENT>
<的TextView
  机器人:ID =@ + ID / custLabel
  机器人:layout_height =WRAP_CONTENT
  机器人:layout_weight =35
  机器人:layout_width =0dip
  机器人:文字=名称/>
<的EditText
  机器人:ID =@ + ID /客户
  机器人:layout_height =WRAP_CONTENT
  机器人:layout_weight =65
  机器人:layout_width =0dip/>
< / LinearLayout中>


解决方案

更改布局的方向。你拥有了它纵放东西在那里,加权宽度!

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>

解决方案

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

这篇关于Android的重量不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆