【问题标题】:Android layout or buttonAndroid 布局或按钮
【发布时间】:2013-01-14 19:25:37
【问题描述】:

我遇到了一个似乎与布局相关的 Android APP 问题。附上图片,您会看到“警报”按钮伸出来,看起来与其他按钮不同。我已将图像替换为已知良好的图像,但问题仍然存在。

有人建议这是因为它是 tabhost 布局,但所有建议的更改都没有奏效。到目前为止,我已经尝试将属性从 android:height 和 width 更改为“wrap_content”、“fill_parent”和“match_parent”。匹配导致另一个奇怪的空白被纠正,但这个按钮是我最后一个明显的挑战。

这是布局代码,你能告诉我问题是什么吗?

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<Button
    android:id="@+id/btnSearch"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/job_tab_bar_search"
    android:focusable="false"
    android:freezesText="false"
    android:imeOptions="actionNext"
    android:longClickable="false"
    android:paddingLeft="17dp"
    android:text="Search"
    android:textColor="@color/color_text_default"
    android:textSize="12dp"
    android:visibility="visible" />

<Button
    android:id="@+id/btnHistory"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/job_tab_bar_history"
    android:paddingLeft="25dp"
    android:text="History"
    android:textColor="@color/color_text_default"
    android:textSize="12dp" />

<Button
    android:id="@+id/btnFavorites"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/job_tab_bar_favorites"
    android:paddingLeft="30dp"
    android:text="Favorites"
    android:textColor="@color/color_text_default"
    android:textSize="12dp" />

<Button
    android:id="@+id/btnAlerts"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/job_tab_bar_alerts"
    android:paddingLeft="12dp"
    android:text="Alerts"
    android:textColor="@color/color_text_default"
    android:textSize="12dp" />

</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.32" >
    </FrameLayout>
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </TabWidget>
</LinearLayout>
</TabHost>

【问题讨论】:

    标签: android xml layout android-tabhost


    【解决方案1】:

    你会认为有人会回复,结果很愚蠢。

    答案是:

    使用 tabactivity 的 Tabhost 将通过调整菜单项的大小来显示背景。向架构添加颜色编码(html 表示法)颜色,然后使用 android:border-background 构造调用它。

    【讨论】:

      猜你喜欢
      • 2013-03-09
      • 2011-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-22
      • 1970-01-01
      相关资源
      最近更新 更多