设计一个安卓边框中带有提示的页面的代码
时间: 2024-05-14 22:12:11 浏览: 16
以下是一个简单的安卓边框中带有提示的页面的代码:
activity_main.xml:
```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:background="@drawable/border">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="这是一个带有提示的页面"
android:layout_gravity="center"/>
</FrameLayout>
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_info"
android:layout_alignTop="@+id/textView"
android:layout_alignRight="@+id/textView"
android:layout_marginTop="-24dp"
android:layout_marginRight="-24dp"/>
</RelativeLayout>
```
border.xml:
```
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="2dp" android:color="#000000"/>
<corners android:radius="8dp"/>
<padding android:left="16dp" android:top="16dp" android:right="16dp" android:bottom="16dp"/>
</shape>
```
此代码使用RelativeLayout作为根布局,包含一个带有边框的FrameLayout和一个带有提示信息的ImageView。FrameLayout中包含一个带有“这是一个带有提示的页面”文本的TextView。
边框是通过使用border.xml作为背景来实现的。ImageView在TextView的右上角,与TextView重叠,并使提示图标显示在边框内。
运行此代码,您将看到一个带有边框和提示的页面。当用户点击提示图标时,您可以将其链接到其他操作或显示更多信息。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)