android中的按钮大小调整

android中的按钮大小调整,android,android-layout,Android,Android Layout,我使用我的布局代码作为 <LinearLayout android:orientation="horizontal" android:background="@android:drawable/bottom_bar" android:paddingLeft="4.0dip" android:paddingTop="5.0dip" android:paddingRight="4.0dip

我使用我的布局代码作为

<LinearLayout android:orientation="horizontal" android:background="@android:drawable/bottom_bar"
    android:paddingLeft="4.0dip" android:paddingTop="5.0dip"
    android:paddingRight="4.0dip" android:paddingBottom="1.0dip"
    android:id="@+id/select_names_tags_ll1"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">
    
    <Button android:id="@+id/button1"
            android:layout_width="0.0dip"
            android:text="ZZZZZZZZZZZZZ"
            android:layout_weight="1.0"
            android:layout_height="wrap_content"
            android:padding="5dp" />
    <Button android:id="@+id/button2"
            android:layout_width="10.0dip"
            android:text="KKKKK"
            android:layout_weight="1.0"
            android:layout_height="wrap_content"
            android:padding="5dp"/>
    <Button android:id="@+id/button3"
            android:layout_width="10.0dip"
            android:text="YYY"
            android:layout_weight="1.0"
            android:layout_height="wrap_content"
        

android:padding="5dp"/>

其输出为

我想确定按钮的宽度取决于它们的文本长度。怎么可能呢

android:layout_width="wrap_content"

这肯定会有帮助。要进行更多自定义,请尝试使用布局权重和权重和属性

您必须按如下方式设置按钮的宽度:

android:layout_width="wrap_content"
您必须从按钮中删除以下内容:

android:layout_weight="1.0"

移除重量标签并为宽度提供包裹内容