framework下添加资源文件方法

本文介绍了一种自定义的关机滑块UI实现方法,包括XML布局设计、资源文件配置及各元素的具体参数设置。此外,还详细说明了如何在Android系统中正确声明和使用这些自定义组件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="match_parent" 
	android:layout_height="match_parent"
	android:orientation="horizontal"
	android:gravity="center">
	android:id="@+id/root">
	<!-- 关机滑块 -->
	 <FrameLayout
	    android:id="@+id/slide_layout"
		android:layout_marginTop="50dip"
		android:layout_marginLeft="30dip"
	 	android:layout_width="match_parent"
		android:layout_height="wrap_content">
		
	 <FrameLayout
	    android:id="@+id/gradientView_layout"
	 	android:layout_width="match_parent"
		android:layout_height="wrap_content">
		
	 	<com.android.server.policy.GradientPowerView    	
	        android:id="@+id/gradientView"
			android:layout_gravity="center"
			android:layout_width="match_parent"
			android:layout_height="75dip"
			android:layout_centerVertical="true"
			android:text="@string/slide_to_poweroff"
			android:textSize="16sp"
			android:textColor="#505050"
			android:SlideColor="#FFFFFF"
	         /> 
		</FrameLayout>

	</FrameLayout>

上面这段 xml中添加的元素

添加方法

1.添加整个xml的名字到public.xml里声明 ,id 根据最末一个值的id号增加 eg:

  <public type="layout" name="iphone_shutdown_dialog" id="0x01090018" />
2.这个xml里的子layout布局需要添加到symbols.xml里声明 eg:

<java-symbol type="id" name="gradientView_layout" />
3.自定义的id需要到  public.xml中声明 eg:

<public type="id" name="gradientView" id="0x0102003d" />

4.string资源文件的添加 需要到./frameworks/base/core/res/res/values/trings.xml  根据国际化选择不同的value目录

5.图片资源的添加 需要将图片资源名字在public.xml里声明eg:

<public type="drawable" name="slide_touch_icon" />

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值