设计布局就像在android的iphone [英] Designing Layout like iphone in android
问题描述
我想设计类似这在 android..See的按钮栏 - >新政,NewCoupons,新类别
I want to design something like this in android..See the Buttons Bar -> New Deals, NewCoupons, New Categories.
再次看到按钮栏的顶部 - >它类似水平滚动视图
Again see the top portion of that Buttons Bar -> Its something like horizontal scroll view.
如何设计这种类型的android的布局。 ?
How to design such type of layouts in android. ?
推荐答案
请参阅本类的 HTTP://$c$c.google.com/p/deezapps-widgets/ 实施水平滚动视图
See this class http://code.google.com/p/deezapps-widgets/ for implementing a horizontal scroll view.
按钮栏可以使用TabWidget声子建议实施。
The buttons bar can be implemented using a TabWidget as Phonon suggests.
要实现一个按钮栏
- 呼叫tabSpec.setIndicator(buildIndicator(TABNAME))
-
喜欢的东西建立你的看法:
- Call tabSpec.setIndicator(buildIndicator(tabName))
Build your view with something like:
private View buildIndicator(String text) {
final TextView indicator = (TextView) getLayoutInflater().inflate(R.layout.tab_indicator, null);
indicator.setText(text);
return indicator;
}
tab_indicator.xml:
tab_indicator.xml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tab_label"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textColor="@color/white"
android:gravity="center"
android:textSize="14sp"
android:textStyle="bold"
android:minHeight="38dp"
android:background="@drawable/bgtab"/>
bgtab是选择与绘制
bgtab is a selector drawable with
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/bg_tab_default"
/>
<item
android:state_selected="false"
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/bg_tab_default"
/>
<item
android:state_selected="true"
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/bg_tab_selected"
/>
<item
android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/bg_tab_selected"
/>
这是大多来自谷歌I / O的应用程序。 bg_tab_selected /默认将其扩大将形如按钮时9补丁PNG图像。
This is mostly from the Google I/O app. bg_tab_selected/default will be 9-patch PNGs which when expanded will be shaped like buttons.
这篇关于设计布局就像在android的iphone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!