iphone - 如何在android中制作iphone风格的菜单栏

标签 iphone android menu

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

最佳答案

在我看来,复制 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>

关于iphone - 如何在android中制作iphone风格的菜单栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7019793/

相关文章:

android - ConstraintLayout 无法与 Android XML Preview 中的其他类一起实例化

c - Linux 命令菜单(例如 ls、ipconfig 等),用于 fork 并使用 execl 将命令作为子进程运行

html - 如何修复图像上的透明菜单?

iphone - 为什么像 NSString 这样的属性在没有内存分配的情况下工作,而 UITextField 的属性不工作,除非我为它分配空间......?

iphone - 位置设置与功耗统计

ios - 在没有 pod 的情况下导入 AFNetworking

html - 我的下拉菜单的内容关闭得太快

iphone - 如何构建类似 iPad App 的终端

android - 在 GSON 中反序列化动态数组

Android 蓝牙 LE 和经典蓝牙 API