我正在尝试实现从屏幕右侧打开的简单NavigationDrawer。我想使用自定义布局而不是ListView / RecyclerView。运行应用程序时,抽屉占据了整个屏幕而不是我指定的320dp?我在这里想念什么?
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/app_bar"
layout="@layout/common_app_bar" />
<com.veriori.veriori.view.VerioriLayout
android:id="@+id/layer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.veriori.veriori.view.VerioriLayout>
</FrameLayout>
<RelativeLayout
android:layout_width="320dp"
android:layout_height="match_parent"
android:background="@color/white"
android:gravity="end">
<ImageView
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_alignParentEnd="true"
android:layout_margin="21dp"
android:background="@drawable/ic_cross" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="26dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/drawer_item_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:background="@drawable/ic_drawer_start" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14dp"
android:text="@string/drawer_start"
android:theme="@style/TextAppearance_5" />
</LinearLayout>
<LinearLayout
android:id="@+id/drawer_item_history"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="21dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:background="@drawable/ic_drawer_history" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14dp"
android:text="@string/drawer_history"
android:theme="@style/TextAppearance_5" />
</LinearLayout>
<LinearLayout
android:id="@+id/drawer_item_report"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="21dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:background="@drawable/ic_drawer_report" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14dp"
android:text="@string/drawer_report"
android:theme="@style/TextAppearance_5" />
</LinearLayout>
<LinearLayout
android:id="@+id/drawer_item_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="21dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:background="@drawable/ic_drawer_settings" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14dp"
android:text="@string/drawer_settings"
android:theme="@style/TextAppearance_5" />
</LinearLayout>
<TextView
android:id="@+id/drawer_manufacturers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="36dp"
android:layout_marginTop="21dp"
android:text="@string/drawer_manufacturers"
android:textColor="@color/colorSecondaryText"
android:theme="@style/TextAppearance_3" />
<TextView
android:id="@+id/drawer_about"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="36dp"
android:layout_marginTop="14dp"
android:text="@string/drawer_veriori"
android:textColor="@color/colorSecondaryText"
android:theme="@style/TextAppearance_3" />
<TextView
android:id="@+id/drawer_agreements"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="36dp"
android:layout_marginTop="14dp"
android:text="@string/drawer_agreements"
android:textColor="@color/colorSecondaryText"
android:theme="@style/TextAppearance_3" />
</LinearLayout>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
答案 0 :(得分:-1)
代替
app.Selection.Find.Font.Bold = -1; //true
//app.Selection.Find.ClearFormatting();
app.Selection.Find.Font.NameAscii = fontname;
app.Selection.Find.Forward = true;
isFind = app.Selection.Find.Execute("", nothing, nothing, nothing, nothing, nothing, app.Selection.Find.Forward, nothing,
app.Selection.Find.Font.Bold, nothing, nothing, nothing, nothing, nothing, nothing);
if (isFind)
{
font_list_bold.Add(fontname + "+Bold");
}
替换为:
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
并从您的RelativeLayout中删除320dp值。
希望这对您有帮助...