android - 在 Android 的仪表板中需要帮助

标签 android android-layout dashboard

我已经为我的应用创建了仪表板。在那我也添加了搜索按钮。我希望将此按钮对齐到右侧,但为此我不想使用边距。我已经添加了我的布局+代码的图像。

已更新

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF"
    android:orientation="vertical" >
    <RelativeLayout style="@style/TitleBar" >

    <ImageView
        android:id="@+id/logo"
        style="@style/TitleBarLogo"
        android:layout_toRightOf="@id/titlebar"
        android:contentDescription="Logo"
        android:src="@drawable/logo" />

    <ImageView
        style="@style/TitleBarSeparator"
        android:layout_toRightOf="@id/logo"
        android:visibility="visible" />

    <ImageButton
        style="@style/TitleBarAction"
        android:layout_alignParentRight="true"
        android:contentDescription="Searching..."
        android:onClick="onClickSearch"
        android:src="@drawable/title_search" />
</RelativeLayout>
<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/titlebar"
        android:layout_weight="1"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dip"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/home_btn_feature1"
                style="@style/HomeButton"
                android:drawableTop="@drawable/home_button1"/>

            <Button
                android:id="@+id/home_btn_feature2"
                style="@style/HomeButton"
                android:drawableTop="@drawable/home_button2"                    
                />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dip"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/home_btn_feature3"
                style="@style/HomeButton"
                android:drawableTop="@drawable/home_button3"/>

            <Button
                android:id="@+id/home_btn_feature4"
                style="@style/HomeButton"
                android:drawableTop="@drawable/home_button4"/>
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>

已更新

样式.xml

<style name="TitleBar">
        <item name="android:id">@id/titlebar</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:orientation">horizontal</item>
        <item name="android:background">@color/title_background</item>
    </style>

    <style name="TitleBarLogo">
        <item name="android:id">@id/title_logo</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:clickable">true</item>
    </style>

    <style name="TitleBarAction">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:background">@drawable/title_button</item>
    </style>
<style name="TitleBarSeparator">
        <item name="android:layout_width">1px</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:background">@color/title_separator</item>
    </style>

OLD

NEW UPDATED

更新了我的代码,只需一步即可完成。分隔符有些不可见。

如果有人有任何想法,请帮助我。

谢谢

最佳答案

尝试

<ImageButton
        style="@style/TitleBarAction"
        android:contentDescription="Searching..."
        android:onClick="onClickSearch"
        android:layout_alignParentRight="true"
        android:src="@drawable/title_search" />

关于android - 在 Android 的仪表板中需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9808695/

相关文章:

android - 如何在 flutter 中对齐卡片 View 中心

java - 当我尝试在 Activity 的 onCreate() 方法中设置不同的内容 View 时,为什么会出现此 RuntimeException?

使用recyclerview时Android fragment 滚动所有元素

android - NavigationView/DrawerLayout中独立的checkableBehavior ="single"组

css - 如何删除应用于 wordpress 仪表板上的 css 规则?

r - R 中的信息仪表板与 ggplot2

android - 当 RecyclerView 上方的顶部菜单可见然后消失时,RecyclerView 会松开之前的位置并跳转到零位置

java - 创建和使用 java web 服务连接远程 mysql 服务器

android - 弹出菜单从操作栏中的图标展开/折叠

css - 具有 2 个部分的嵌套网格显示不一致的行大小和重叠元素