在屏幕底部有标签的Android?
我试图将选项卡放在屏幕的底部,并让每个选项卡显示不同的活动。在屏幕底部有标签的Android?
但是,从我读过的,你只能在手机上使用3.0+。
当我知道的大多数手机都在2.3左右时,这看起来有些荒谬。
任何人有任何想法?
您可以通过底部的碎片和一组按钮来实现最佳效果。
所以当点击一个按钮时,无论用户点击了什么,都可以在主要内容区域进行片段转换。
这就是说,底部的标签在Android上是不好的形式。
只是做了一些片段阅读......可以在版本 droider 2012-08-07 03:08:48
是的,使用支持库jar,这有支持回到1.6。 – 2012-08-07 03:18:59
这可以使用了Android常用的标签,只是你需要做的就是添加在xml.I一些额外的代码希望这段代码可以帮助你得到它完成实现...
<TabHost
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:background="@android:color/background_dark"
>
<RelativeLayout
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_above="@android:id/tabs">
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
style="@style/customtab"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
</TabWidget>
</RelativeLayout>
</TabHost>
风格在这里@风格/自定义标签
<style name="customtab" parent="@android:style/Widget.TabWidget">
<item name="android:tabStripEnabled">false</item>
<item name="android:tabStripLeft">@null</item>
<item name="android:tabStripRight">@null</item>
</style>
下面的标签栏使用下面的XML代码。
<?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" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="3dp" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@android:id/tabs"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</TabHost>
并使用下面的java代码。
public class MainActivity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_screen);
TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Home", getResources().getDrawable(R.drawable.home)).setContent(new Intent(this, HomeActivity.class)));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("Second", getResources().getDrawable(R.drawable.invoice)).setContent(new Intent(this, SecondActivity.class)));
tabHost.setCurrentTab(0);
}
}
底部选项卡是iOS设计模式。他们可以在Android上感觉很外国:http://developer.android.com/design/patterns/pure-android.html – Krylez 2012-08-07 03:48:37
参考这个http://*.com/questions/2395661/android-tabs-at-the-底部 – KMI 2012-08-07 04:28:57
只是不,不是真的,不要。 – 2012-08-07 05:31:43