Android studio 之 Menu(菜单)

Android studio 之 Menu(菜单)

一、菜单资源及选项菜单

首先,新建好项目后,删除layout文件夹及java的com.example.menutouch文件夹下所有文件
图1
图2
图3
在layout文件夹下新建xml文件menu_layout.xml,使用线性布局LinearLayout,在线性布局里添加文本TextView和图片ImageView控件。
图4

<?xml version="1.0" encoding="utf-8"?>
//第一行代码为固定代码,不可改变
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android" >

    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textSize="30dp"
        android:text="选项菜单测试" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:background="@drawable/ic_launcher_background" />
</LinearLayout>

在AndroidManifest.xml文件中,需要手动添加一个最低和目标SDK版本为19。

   <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="19">
    </uses-sdk>

删除如下圈出的一行文字,这行文字是文件新建是自带的,表示不带的动作条。
图6
利用

  • 6
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值