Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android视图-动态设置宽度_Android_Android Layout_Width_Android Linearlayout - Fatal编程技术网

Android视图-动态设置宽度

Android视图-动态设置宽度,android,android-layout,width,android-linearlayout,Android,Android Layout,Width,Android Linearlayout,这是我需要完成的,我的菜单分隔符的宽度应该等于我的第二个线性布局(换行内容)的宽度 因此,我需要获得第二个线性布局的宽度,并将其设置为我的菜单分隔符。 我该怎么做? 谢谢 我明白了。我只是将宽度设置为与父项匹配。顺便说一句,这个布局是一个弹出窗口,所以匹配家长回答它 我明白了。我只是将宽度设置为与父项匹配。顺便说一句,这个布局是一个弹出窗口,所以匹配家长回答它 试试这个 <LinearLayout android:layout_width="wrap_content"

这是我需要完成的,我的菜单分隔符的宽度应该等于我的第二个线性布局(换行内容)的宽度

因此,我需要获得第二个线性布局的宽度,并将其设置为我的菜单分隔符。 我该怎么做? 谢谢



我明白了。我只是将宽度设置为与父项匹配。顺便说一句,这个布局是一个弹出窗口,所以匹配家长回答它

我明白了。我只是将宽度设置为与父项匹配。顺便说一句,这个布局是一个弹出窗口,所以匹配家长回答它

试试这个

<LinearLayout 
      android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:orientation="vertical"
    >
    <LinearLayout  
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:minWidth="174dp"
    android:padding="8dip" >

    <ImageView
        android:id="@+id/itemImage"
        android:layout_width="25dip"
        android:layout_height="25dip"/>

    <TextView
        android:id="@+id/itemLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="hwlloo nanfkjfouiofr dashjfkhal sdhf"/>

</LinearLayout>

<View
    android:id="@+id/menu_divider"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="#ff0000"
    android:visibility="visible" />

</LinearLayout>

试试这个

<LinearLayout 
      android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:orientation="vertical"
    >
    <LinearLayout  
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:minWidth="174dp"
    android:padding="8dip" >

    <ImageView
        android:id="@+id/itemImage"
        android:layout_width="25dip"
        android:layout_height="25dip"/>

    <TextView
        android:id="@+id/itemLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="hwlloo nanfkjfouiofr dashjfkhal sdhf"/>

</LinearLayout>

<View
    android:id="@+id/menu_divider"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="#ff0000"
    android:visibility="visible" />

</LinearLayout>