Android 10.0 仿ios的hotseat效果修改hotseat样式

1.概述

在10.0的系统产品开发中,在最近项目需求的需要,hotseat效果要仿ios一样不需要全屏的效果 居中显示就行了,所以就要看hotseat的具体布局显示了
效果图如下:

在这里插入图片描述

2.仿ios的hotseat效果修改hotseat样式的核心类

packages/apps/Launcher3/res/layout/launcher.xml
/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java

3.仿ios的hotseat效果修改hotseat样式的核心功能分析和实现

在Launcher3中主页面的布局是在laucher.xml中,所以
接下来先看hotseat布局 在laucher.xml中

3.1laucher.xml相关源码分析

<com.android.launcher3.LauncherRootView
 
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
以下是一个简单的安卓仿iOS hotseat界面的示例代码: 1. 创建一个新的安卓项目。 2. 在`activity_main.xml`文件中添加以下代码: ```xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- 底部 hotseat 区域 --> <LinearLayout android:id="@+id/hotseat" android:layout_width="match_parent" android:layout_height="64dp" android:layout_alignParentBottom="true" android:background="@color/white" android:orientation="horizontal" android:weightSum="5"> <!-- 自定义图标和标题的图标按钮 --> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_home" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Home" android:textColor="@color/black" android:textSize="12sp" /> </LinearLayout> <!-- 其他图标按钮 --> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_search" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Search" android:textColor="@color/black" android:textSize="12sp" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_add" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add" android:textColor="@color/black" android:textSize="12sp" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_star" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Favorites" android:textColor="@color/black" android:textSize="12sp" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_settings" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Settings" android:textColor="@color/black" android:textSize="12sp" /> </LinearLayout> </LinearLayout> <!-- 其他内容区域 --> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@id/hotseat" android:background="@color/gray" android:orientation="vertical"> <!-- 在此添加其他内容 --> </LinearLayout> </RelativeLayout> ``` 3. 在`MainActivity.java`文件中添加以下代码: ```java public class MainActivity extends AppCompatActivity { private LinearLayout hotseat; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); hotseat = findViewById(R.id.hotseat); // 遍历 hotseat 区域中的所有 LinearLayout,并为它们添加点击事件 for (int i = 0; i < hotseat.getChildCount(); i++) { final LinearLayout item = (LinearLayout) hotseat.getChildAt(i); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // 在此处理点击事件 Toast.makeText(MainActivity.this, ((TextView) item.getChildAt(1)).getText(), Toast.LENGTH_SHORT).show(); } }); } } } ``` 这样,当用户点击 hotseat 区域的任何一个图标按钮时,都会弹出一个提示框显示该按钮的标题。 注意,这只是一个简单的示例代码,您可能需要对其进行修改以适应您的应用程序。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

安卓兼职framework应用工程师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值