android 自定义标题未横向填充父级

发布于 2024-12-19 10:36:08 字数 1011 浏览 3 评论 0原文

我已经自定义了我的标题栏。 问题是虽然我已经提到宽度作为 fill_parent 它不填充父级 两边都有一些空格,

代码位于

<resources>
    <style name="LargeTitleTheme">
        <item name="android:windowTitleSize">40dip</item>
    </style>
</resources>

xml2:

<RelativeLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView android:id="@+id/textview" android:textStyle="bold"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:gravity="center" android:text="fggffgjjkki"
            android:textSize="30sp"
                        android:textColor="#FFFFFF" android:background="@drawable/top_bar" />
</RelativeLayout>

代码下面:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.homegrid);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.customtitle);

I have customised my title bar.
The problem is though i have mentioned the width as fill_parent its not filling parent
with some blank space on either sides

the code is below

<resources>
    <style name="LargeTitleTheme">
        <item name="android:windowTitleSize">40dip</item>
    </style>
</resources>

xml2:

<RelativeLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView android:id="@+id/textview" android:textStyle="bold"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:gravity="center" android:text="fggffgjjkki"
            android:textSize="30sp"
                        android:textColor="#FFFFFF" android:background="@drawable/top_bar" />
</RelativeLayout>

code:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.homegrid);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.customtitle);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画中仙 2024-12-26 10:36:09

尝试将 android:layout_marginLeft="0dp" android:layout_marginRight="0dp" 添加到relativelayout。

Try adding android:layout_marginLeft="0dp" android:layout_marginRight="0dp" to the RelativeLayout.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文