[英]how to properly customiz the action bar in android
I have a problem with customazing the actionbar in android that in the designer of eclipse i have the design looks like that 我在自定义android中的操作栏时遇到问题,在eclipse的设计器中我的设计看起来像这样
well this is what i want 好吧,这就是我想要的
but when i run the app i got this 但是当我运行该应用程序时,我得到了这个
the code of the actionbar is 操作栏的代码是
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Cover"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF9800"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingBottom="8dp"
android:paddingTop="8dp" >
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:clickable="true"
android:src="@drawable/ic_menu_white_36dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right|center_vertical"
android:orientation="horizontal" >
<ImageView
android:id="@+id/coverhidden"
android:layout_width="36dp"
android:layout_height="36dp"
android:visibility="gone" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/profil_infos_rect"
android:drawableLeft="@drawable/ic_search_white_24dp"
android:hint=" Search"
android:padding="4dp"
android:textColor="#fff"
android:textColorHint="#FFFFFF"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/iconmsg"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:clickable="true"
android:src="@drawable/ic_msg" />
</LinearLayout>
</LinearLayout>
well i uses i triky way to solve this by my self 好吧,我用怪诞的方式来解决这个问题
i just use relativelayout so the code will be like that 我只是使用relativelayout,所以代码将像这样
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Cover"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF9800"
android:orientation="horizontal"
android:paddingTop="4dp" >
<ImageView
android:id="@+id/drawerleft"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignParentLeft="true"
android:layout_gravity="center"
android:layout_margin="4dp"
android:clickable="true"
android:src="@drawable/ic_menu_white_36dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="52dp"
android:layout_marginTop="4dp"
android:layout_toLeftOf="@+id/iconmsg"
android:layout_toRightOf="@+id/drawerleft"
android:background="@drawable/profil_infos_rect"
android:drawableLeft="@drawable/ic_search_white_24dp"
android:gravity="center_vertical"
android:hint=" Search"
android:padding="4dp"
android:textColor="#fff"
android:textColorHint="#FFFFFF"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/iconmsg"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:layout_margin="4dp"
android:clickable="true"
android:src="@drawable/ic_msg" />
</RelativeLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.