Android 如何在操作栏上垂直分割图像按钮
我已经做了一个自定义主题,以显示我的图像按钮在行动栏。我想知道如何在android中垂直居中这些按钮 到目前为止我编写的代码Android 如何在操作栏上垂直分割图像按钮,android,android-layout,Android,Android Layout,我已经做了一个自定义主题,以显示我的图像按钮在行动栏。我想知道如何在android中垂直居中这些按钮 到目前为止我编写的代码 <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left|center_vertical"
android:background="@drawable/groups" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center|fill_vertical"
android:background="@drawable/contactlist" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right|center_vertical"
android:background="@drawable/favourites" />
</FrameLayout>
这就是我想要的
您可以将图像按钮放置在垂直方向的
线性布局中,然后将其重力设置为android:layout\u gravity=“center”//试试这个
请遵循此代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageButton
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_gravity="top|left|center_vertical"
android:layout_weight="1"
android:background="#FE6602" />
<ImageButton
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_gravity="top|center|fill_vertical"
android:layout_weight="1"
android:background="#DBEAF9" />
<ImageButton
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_gravity="top|right|center_vertical"
android:layout_weight="1"
android:background="#FAF2B0" />
</LinearLayout>
我只是把简单的颜色和静态大小或测试目的的工作,如魅力。如果使用线性布局,那么我可以把图像按钮放在左边、右边和中间。我不想硬编码任何利润values@user123456你能发布一张你想要实现的截图或图画吗?是的,我刚刚上传了一张我想要的图片。你为什么不使用标签呢?查看是否使用制表符,则无法使用ListAdapter来显示列表。所以我必须使用动作条检查我的答案。好的
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageButton
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_gravity="top|left|center_vertical"
android:layout_weight="1"
android:background="#FE6602" />
<ImageButton
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_gravity="top|center|fill_vertical"
android:layout_weight="1"
android:background="#DBEAF9" />
<ImageButton
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_gravity="top|right|center_vertical"
android:layout_weight="1"
android:background="#FAF2B0" />
</LinearLayout>
android:layout_height="50dip" to android:layout_height="wrap_content"
android:background="#FE6602" to android:background="@drawable/contactlist"