Android之抽屉式弹窗功能

目录

ps:如果你觉得对你有帮助的话,麻烦点个赞加个关注

  • 效果图:

  • 代码:

效果图:

Android之抽屉式弹窗功能_第1张图片
Android之抽屉式弹窗功能_第2张图片

代码:

res/layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg"
    tools:context=".MainActivity">

    <!--设置抽屉控件-->
    <SlidingDrawer
        android:id="@+id/drawer1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:content="@+id/myView"
    android:handle="@+id/layout1"
    android:orientation="horizontal">
    <!--设置引导按钮-->
    <LinearLayout
        android:id="@id/layout1"
    android:layout_width="35dp"
    android:layout_height="match_parent"
    android:gravity="center">
    <ImageView
        android:id="@+id/myImage1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/open" />
    </LinearLayout>
    <!--设置抽屉内容-->
    <ImageView
    android:id="@+id/myView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/iv_bg" />
    </SlidingDrawer>





</RelativeLayout>

res/values/strings.xml

<resources>
    <string name="app_name">公告</string>
</resources>

res/values/styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="@android:style/Theme.NoTitleBar.Fullscreen">


    </style>

</resources>
package com.example.announcementdrawer;



import android.app.Activity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.SlidingDrawer;

public class MainActivity extends Activity {
     

    @Override
    protected void onCreate(Bundle savedInstanceState) {
     
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

你可能感兴趣的:(Android,android,移动开发)