Android的:如何使的LinearLayout相同尺寸内的所有元素?元素、尺寸、Android、LinearLayout

2023-09-12 21:40:35 作者:疼了╮自然会松手

我想创建一个对话框来显示视频标题和标签。下面的文字我想补充的按钮查看,编辑和删除,使这些元素的大小相同。有谁知道如何修改的.xml布局文件,以使LinearView大小相同中的元素?

I would like to create a dialog to display a video title and tags. Below text I would like to add buttons View, Edit and Delete and make these elements same size. Does anyone know how to modify .xml layout file in order to make elements inside LinearView same size?

目前的布局文件看起来是这样的:

The current layout file looks like this:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:orientation="vertical">

    <LinearLayout 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:orientation="vertical">

          <TextView 
              android:layout_width="wrap_content" 
              android:layout_height="wrap_content" 
              android:id="@+id/txtTitle" android:text="[Title]" >
          </TextView>

          <TextView 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" 
              android:id="@+id/txtTags"            
              android:text="[Tags]" >
          </TextView>

    </LinearLayout>

    <LinearLayout 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal">

        <Button 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:id="@+id/btnPlay" 
           android:text="View">
        </Button>

        <Button 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:id="@+id/btnEdit" 
            android:text="Edit">
        </Button>

        <Button 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:id="@+id/btnDelete" 
            android:text="Delete">
        </Button>

    </LinearLayout>

</LinearLayout>

我会AP preciate如果有人能证明该解决方案通过修改粘贴的文件内容。

I would appreciate if anyone could show the solution by modifying the pasted file content.

谢谢!

推荐答案

使用机器人:layout_width =0px​​的android:layout_weight = 1上的三个按钮秒。这说的按钮应该承担不超过0像素,但他们三个人应该分开他们之间的任何额外的空间。这应该给你你想要的视觉效果。

Use android:layout_width="0px" and android:layout_weight="1" on the three Buttons. That says the buttons should take up no more than 0 pixels, but the three of them should split any extra space between them. That should give you the visual effect you wish.