【问题标题】:How to make an iphone style menu bar in android如何在android中制作一个iphone风格的菜单栏
【发布时间】:2011-08-11 01:16:51
【问题描述】:

我正在尝试将 iphone 应用程序移植到 android。应用程序内部有一个带有五个按钮的静态栏,其作用类似于菜单栏(即单击一个按钮将打开相应的页面)此栏不会消失,它应该根据按下的按钮亮起。我不知道如何开始,并且想知道是否有人可以给我一些帮助。这是按钮。谢谢

【问题讨论】:

标签: iphone android menu


【解决方案1】:

在我看来,复制 iPhone 应用程序不是一个好主意。 用户界面(因此用户行为)与 iPhone 和 Android 设备完全不同。问问自己“这是在 Android 上做这件事的正确方法吗?”如果您不确定,请不要这样做。但要像其他 Android 开发者那样做。

您可以按照本教程开始 http://developer.android.com/resources/tutorials/views/hello-tabwidget.html 然后(仅当您理解它时)为您的每个选项卡尝试类似的操作:

// Initialize a TabSpec for each tab and add it to the TabHost

spec = mTabHost.newTabSpec("Name of tab");
v = View.inflate(this, R.layout.tabbar_tabview, null);
((ImageView)v.findViewById(R.id.tabbar_tabview_img)).setBackgroundResource(R.drawable.ic_tab_expenses);
((TextView)v.findViewById(R.id.tabbar_tabview_text)).setText(R.string.general_tab_expenses);
spec.setIndicator(v);
spec.setContent(intent);
mTabHost.addTab(spec);

这是我的“tabbar_tabview.xml”的内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:padding="0dp"
    android:layout_height="fill_parent" android:layout_width="fill_parent"
        android:background="@drawable/tabview_background">

    <ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:id="@+id/tabbar_tabview_img"
        android:layout_gravity="center" android:layout_marginTop="5dp"></ImageView>

    <TextView  android:id="@+id/tabbar_tabview_text" android:layout_width="wrap_content"
        android:gravity="center" android:layout_height="wrap_content" android:textSize="13dp" android:layout_marginBottom="5dp"
        android:layout_gravity="center" android:textColor="@drawable/tabview_text_color"></TextView>

</LinearLayout> 

这是我的 tabview_background.xml 的内容:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true">
        <shape>
             ### I defined a shape here ###
        </shape>
    </item>

    <item>
        <shape>
             ### I defined a shape here ###
        </shape>
    </item>
</selector>

【讨论】:

  • @Gibou - 优秀的回应(+1):“在我看来,复制 iPhone 应用程序不是一个好主意。用户界面(以及用户行为)完全不同,iPhone和 Android 设备”
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多