安卓ICS到JB动作条的标签更改的要求 [英] Android ICS to JB Actionbar tabs changed requirements
问题描述
我有一个目标SDK 15,ICS 4.0.3的应用程序。我刚刚更新为指向4.1它打破了我的用户界面,并使得它pretty的丑陋:
I have an application that targets SDK 15, ICS 4.0.3. I just updated it to point at 4.1 it broke my user interface, and makes it pretty ugly:
下面是它看起来像正常的API 15:
Here's what it looks like normally on API 15:
这是它在16或17:
And here's it on 16 or 17:
我有一种感觉,这是因为的Nexus 7使用手机的用户界面,而不是实际的平板电脑用户界面......有没有办法迫使接头插入动作条,而无需使用类似动作条福尔摩斯还是其他什么东西(如子类化)?甚至,如果我可以使标签没有看起来可怕,也许如果他们居中的文本?现在的按钮不能连做match_parent。是否有一个缺点定位较低的SDK(我什么都不需要更高的现在)?我的应用程序只能运行在ICS以上。
I got a feeling this is because the Nexus 7 uses the phone UI instead of the actual tablet UI... Is there a way to force the tabs into the actionbar without having to use something like ActionBar sherlock or something else (like subclassing)? Or even if I could make the tabs not look terrible, perhaps if they had centered text? Right now the buttons don't even do match_parent. Is there a downside to targeting a lower SDK (I don't need anything higher right now)? My app only runs on ICS or higher.
推荐答案
我创建了像Instagram那样操作栏的就像一个标签页的,你可以检查我的previous答案,以及如何我做到了。使用手机即时通讯的权利即时通讯无法发布的code作为我的笔记本电脑。反正只是检查我的previous答案。后来我将下降再次和张贴code。
I have created like instagram action bar like a tabs you may check my previous answer and how i did it. Im using phone right im not able to post the code as its on my laptop. Anyway just check my previous answer . Later i will drop by again and post the code.
编辑------
Edit here is the image :).
再次回到了最好的结果:)。你需要做的第一件事就是 创建布局命名为header.xml
back again with a best results :). first thing you need to do is create a layout name it header.xml
<?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="@dimen/action_bar_height"
android:layout_gravity="top"
android:baselineAligned="true"
android:orientation="horizontal" >
<ImageView
android:id="@+id/share"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_weight=".14"
android:background="@drawable/action_bar_left_button"
android:src="@drawable/action_bar_glyph_back" />
<ImageView
android:id="@+id/bright"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".14"
android:background="@drawable/action_bar_left_button"
android:src="@drawable/action_bar_glyph_lux" />
<ImageView
android:id="@+id/rotate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".14"
android:background="@drawable/action_bar_left_button"
android:src="@drawable/rotate" />
<ImageView
android:id="@+id/bright"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".14"
android:background="@drawable/action_bar_left_button"
android:src="@drawable/action_bar_glyph_lux" />
<ImageView
android:id="@+id/rotate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".14"
android:background="@drawable/action_bar_left_button"
android:src="@drawable/rotate" />
<ImageView
android:id="@+id/forwa"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".14"
android:background="@drawable/action_bar_left_button"
android:src="@drawable/forward" />
</LinearLayout>
后去你的MainActivity.class创建此方法。
after that go to your MainActivity.class and create this method.
private void setupActionBar() {
ActionBar actionBar = getActionBar();
//actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
ViewGroup v = (ViewGroup)LayoutInflater.from(this)
.inflate(R.layout.header, null);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(v,
new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
ActionBar.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_VERTICAL | Gravity.RIGHT));
}
添加 setupActionBar();
您的onCreate活动并运行你的应用程序:)
add setupActionBar();
to your onCreate Activity and run your app :).
现在有自定义动作条带分频器和图像PS分压器在布局为图像的背景:)定义。
now you have custom ActionBar with Dividers and Images P.S the divider is defined in the layout as an image background :).
这篇关于安卓ICS到JB动作条的标签更改的要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!