Android 使线性布局占其宽度的百分比';s父容器
有没有办法让Android中的Android 使线性布局占其宽度的百分比';s父容器,android,android-layout,Android,Android Layout,有没有办法让Android中的LinearLayout占据其父容器的一定宽度 在CSS中,它可能看起来像: .elm{最大宽度:70%;} 如何使用LinearLayout和Android实现同样的效果 这与之前提出的问题不同,例如,因为这使得它占据了宽度的一个百分比,所以它没有将最大宽度定义为一个百分比 编辑: 尝试了@jungleboys的建议: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:andro
LinearLayout
占据其父容器的一定宽度
在CSS中,它可能看起来像:
.elm{最大宽度:70%;}
如何使用LinearLayout
和Android
实现同样的效果
这与之前提出的问题不同,例如,因为这使得它占据了宽度的一个百分比,所以它没有将最大宽度定义为一个百分比
编辑:
尝试了@jungleboys的建议:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1.0" >
<LinearLayout
android:id="@+id/bubble_outerWrapper"
android:layout_width="0dp"
android:layout_weight="0.7"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/bubble_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/bubble_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dip"
android:background="@drawable/bubble_yellow"
android:paddingLeft="10dip"
android:text="TextViewwwwwwwwwwwwwwwwwwwwwww!"
android:textColor="@android:color/primary_text_light" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
这行不通,其他人有什么想法吗?试试这种方法,希望这能帮助你解决问题
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/bubble_outerWrapper"
android:layout_width="0dp"
android:layout_weight="0.7"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/bubble_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dip"
android:paddingLeft="10dip"
android:text="TextViewwwwwwwwwwwwwwwwwwwwwww! TextViewwwwwwwwwwwwwwwwwwwwwww! TextViewwwwwwwwwwwwwwwwwwwwwww! TextViewwwwwwwwwwwwwwwwwwwwwww! TextViewwwwwwwwwwwwwwwwwwwwwww!"/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_weight="0.3"
android:layout_height="1"/>
</LinearLayout>