无法在导航抽屉内使用权重?
Cant use weights inside of navigation drawer?
我正在开发一个小型转换器只是为了回到 java 我添加了一个导航抽屉但是元素的布局(按钮、文本视图等)设置得不是很好所以我决定使用权重但是为了由于某些原因,权重使它在 xml 预览中看起来很好,但是当我将应用程序启动到我的 phone 时,它没有显示任何元素。导航抽屉工作得很好,但那里的元素又一无所有,我试图修复它但没有运气任何帮助将不胜感激。提前致谢!!!
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2">
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#121212"
android:layout_weight="1"
android:weightSum="3"
android:orientation="vertical"
tools:context="com.example.stiansformula.MainActivity"
tools:ignore="MergeRootFrame" >
<EditText
android:id="@+id/binarynumber"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_above="@+id/button1"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:layout_marginBottom="36dp"
android:alpha="50"
android:background="#222222"
android:ems="10"
android:fontFamily="sans-serif-condensed"
android:inputType="numberDecimal"
android:textColorLink="#ffffff" >
</EditText>
<TextView
android:id="@+id/bnumtext"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignLeft="@+id/button1"
android:layout_alignParentTop="true"
android:layout_marginTop="19dp"
android:layout_weight="1"
android:text="TextView"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:typeface="sans" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:background="#232323"
android:onClick="calculatebinary"
android:text="Enter" />
</LinearLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:entries="@array/DrawerItems" />
</android.support.v4.widget.DrawerLayout>
以防万一其他人遇到这个问题,这里解决了我的问题"Yeah, never mind that rebuild. Your problem is the if(savedInstanceState == null) block. That FragmentTransaction is hiding the main content in the layout's LinearLayout. Comment out that block, and run it again."此答案由 Mike M 提供,再次感谢 Mike 的帮助。
我正在开发一个小型转换器只是为了回到 java 我添加了一个导航抽屉但是元素的布局(按钮、文本视图等)设置得不是很好所以我决定使用权重但是为了由于某些原因,权重使它在 xml 预览中看起来很好,但是当我将应用程序启动到我的 phone 时,它没有显示任何元素。导航抽屉工作得很好,但那里的元素又一无所有,我试图修复它但没有运气任何帮助将不胜感激。提前致谢!!!
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2">
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#121212"
android:layout_weight="1"
android:weightSum="3"
android:orientation="vertical"
tools:context="com.example.stiansformula.MainActivity"
tools:ignore="MergeRootFrame" >
<EditText
android:id="@+id/binarynumber"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_above="@+id/button1"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:layout_marginBottom="36dp"
android:alpha="50"
android:background="#222222"
android:ems="10"
android:fontFamily="sans-serif-condensed"
android:inputType="numberDecimal"
android:textColorLink="#ffffff" >
</EditText>
<TextView
android:id="@+id/bnumtext"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignLeft="@+id/button1"
android:layout_alignParentTop="true"
android:layout_marginTop="19dp"
android:layout_weight="1"
android:text="TextView"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:typeface="sans" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:background="#232323"
android:onClick="calculatebinary"
android:text="Enter" />
</LinearLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:entries="@array/DrawerItems" />
</android.support.v4.widget.DrawerLayout>
以防万一其他人遇到这个问题,这里解决了我的问题"Yeah, never mind that rebuild. Your problem is the if(savedInstanceState == null) block. That FragmentTransaction is hiding the main content in the layout's LinearLayout. Comment out that block, and run it again."此答案由 Mike M 提供,再次感谢 Mike 的帮助。