每当我尝试增加自定义标题栏的高度时,它都会被它下方的RelativeLayout重叠。
我尝试增加标题的高度,但它正在重叠。 还尝试降低relativeLayout的高度,但也没有工作
请在下面找到我的自定义标题和相关布局。
Windows_title
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:gravity="center_vertical"
android:paddingLeft="5dip"
android:background="#4A148C"
android:weightSum="1">
<ImageView
android:id="@+id/header"
android:src="@drawable/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-5dp"
android:paddingLeft="-10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/title" />
</LinearLayout>
Activity_Main
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context="com.jiq.sagar.javainterviewquestion.MainActivity">
<!--<include layout="@layout/windows_title"
android:id="@+id/include" />-->
<ListView
android:layout_width="wrap_content"
android:id="@+id/listView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="false"
android:background="#00BCD4"
android:clickable="false"
android:divider="#9f9b9b"
android:dividerHeight="2dp"
android:drawSelectorOnTop="false"
android:fastScrollAlwaysVisible="false"
android:fastScrollEnabled="false"
android:focusableInTouchMode="true"
android:longClickable="false"
android:nestedScrollingEnabled="false"
android:choiceMode="singleChoice"
android:layout_height="wrap_content"
android:paddingRight="5dp"
android:smoothScrollbar="true" />
</RelativeLayout>
我使用以下代码设置标题:
protected void onCreate(Bundle savedInstanceState) {
//Log.i(MY_TAG, "mainact");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.windows_title);
setTitle("Interview Question");
dh = new DatabaseHelper(this);
getDatabase();
mainlist();
}
答案 0 :(得分:0)
You can fix this issue in two ways, first uncomment your include layout and choose one of the below answer...
1. use this line in your `ListView` component in `activity_main.xml` :--
`android:layout_below="@+id/include"`
2. change your `activity_main` to `linearLayout` and put orientation to vertical, you can see in code below
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/include"
layout="@layout/window_title" />
<ListView
android:id="@+id/listView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="false"
android:background="#00BCD4"
android:choiceMode="singleChoice"
android:clickable="false"
android:divider="#9f9b9b"
android:dividerHeight="2dp"
android:drawSelectorOnTop="false"
android:fastScrollAlwaysVisible="false"
android:fastScrollEnabled="false"
android:focusableInTouchMode="true"
android:longClickable="false"
android:nestedScrollingEnabled="false"
android:paddingRight="5dp"
android:smoothScrollbar="true" />
</LinearLayout>