我想创建一个 android 界面,类似于启动器。为此,我需要在屏幕的每一侧制作一个自定义标题栏和 2 个边框。
我的应用程序中有多个 Activity ,我需要将其包含在所有 Activity 中,因此我需要创建独立的布局,一个带有自定义标题栏,另一个带有边框。结果可能是这样的:
这是边框的 xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/border_left"
android:layout_width="100dip"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_alignParentLeft="true"
android:background="#000000" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/border_right"
android:layout_width="100dip"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_alignParentRight="true"
android:background="#000000" >
</RelativeLayout>
这是标题的 xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:orientation="horizontal"
android:background="#000000" >
问题是2:
如何在标题栏(红色方 block )中间放置 Logo (图像)?
如何将这 2 个布局插入到其他 Activity 中?例如,如何让我的普通主布局包含这 2 个布局?
最佳答案
第二个问题的答案:将布局包含到另一个布局中:
<include
layout = "@layout/custom_tittlebar" >
</include>
我仍然在与标题栏作斗争,我想把图像放在那个位置,我在想这是否是最好的方式,或者我可能必须使用 photoshop 创建一个图像并在其上设置 Logo ,然后将其设置为布局中的背景。
关于android - 创建布局自定义标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19270634/