大神们帮帮忙,launcher桌面UI的问题

头发还没秃a 2015-06-19 04:10:05
桌面图标刚进入的时候是下图所示:

当选中之后,图中的圆圈和数据会被挡住,如下图所示:

图中显示圆圈和数据的控件是放在另外一个XML文件(layout_memory.xml)里面的,代码如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:gravity="center_vertical"
android:id="@id/memory_container"
android:padding="20.0dip"
android:layout_width="200.0dip"
android:layout_height="200.0dip"
android:layout_marginLeft="900.0dip"
android:layout_marginTop="300.0dip"
android:scaleType="fitXY"
android:layout_alignParentLeft="true"
xmlns:android="http://schemas.android.com/apk/res/android"
>

<TextView
android:textSize="25.0sp"
android:textColor="@color/white"
android:gravity="center"
android:id="@id/memory_used"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/memory_used_empty"
/>

<ImageView
android:id="@id/memory_circle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/memory_circle_image"
/>

</RelativeLayout>


我是在layout_main里面使用include对layout_memory进行关联:

<include layout="@layout/layout_memory" />


layout_memory里面的控件和layout_main里面的控件重叠了,当在选中状态的时候,显示的是放大之后的layout_main里面的控件,layout_memory被挡住了,就算再次取消焦点也会被挡住。
请教怎么让layout_memory.xml始终显示在最上层呢?
...全文
336 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
头发还没秃a 2015-06-23
  • 打赏
  • 举报
回复
引用 16 楼 zhumj_zhumj 的回复:
[quote=引用 15 楼 dalor 的回复:] [quote=引用 13 楼 zhumj_zhumj 的回复:] [quote=引用 10 楼 dalor 的回复:] 你再调整一下吧,是可以的,include相关属性设置一下,显示在最上层,不会扰乱别的布局的。
刚进入桌面的时候确实是显示在最上层的,但是当处于选中状态之后就会被主布局里面的控件给挡住,选中之后会有个按钮变大操作,是选的下面代码的控件来进行的:

<com.amlogic.mediaboxlauncher.MyRelativeLayout
			android:id="@+id/layout_memory"
		    android:layout_width="247dp"
		    android:layout_height="220dp"
		    android:layout_marginTop="40dp"
		   	android:layout_marginLeft="760dp"
		    android:focusable="true"
		    android:focusableInTouchMode="true"
			android:descendantFocusability="afterDescendants"	
			>
    
	    	<ImageView 
            	android:id="@id/img_memory" 
            	android:layout_width="fill_parent" 
            	android:layout_height="fill_parent" 
            	android:src="@drawable/img_memory" 
            	android:layout_centerInParent="true" 
            />
            <TextView 
            	android:textSize="30dp" 
            	android:id="@id/tx_memory" 
            	android:layout_width="wrap_content" 
            	android:layout_height="wrap_content" 
            	android:layout_marginTop="160.0dip" 
            	android:text="@string/str_memory" 
            	android:layout_centerHorizontal="true" 
            />
			
		</com.amlogic.mediaboxlauncher.MyRelativeLayout>
[/quote] 选中后,是下面变大,那前面还要显示不? 不显示就隐了,显示,就在变大后,再把include的布局bringtofront一下看看,不知道你的操作和最张效果要怎么样,总是,肯定是可以实现的。[/quote] 我想要做的效果是layout_memory.xml一直都显示在最上层,不管是选中状态还是没选中状态[/quote] 已经解决了,是在另外一个XML文件进行include引用,哈哈
头发还没秃a 2015-06-19
  • 打赏
  • 举报
回复
引用 15 楼 dalor 的回复:
[quote=引用 13 楼 zhumj_zhumj 的回复:] [quote=引用 10 楼 dalor 的回复:] 你再调整一下吧,是可以的,include相关属性设置一下,显示在最上层,不会扰乱别的布局的。
刚进入桌面的时候确实是显示在最上层的,但是当处于选中状态之后就会被主布局里面的控件给挡住,选中之后会有个按钮变大操作,是选的下面代码的控件来进行的:

<com.amlogic.mediaboxlauncher.MyRelativeLayout
			android:id="@+id/layout_memory"
		    android:layout_width="247dp"
		    android:layout_height="220dp"
		    android:layout_marginTop="40dp"
		   	android:layout_marginLeft="760dp"
		    android:focusable="true"
		    android:focusableInTouchMode="true"
			android:descendantFocusability="afterDescendants"	
			>
    
	    	<ImageView 
            	android:id="@id/img_memory" 
            	android:layout_width="fill_parent" 
            	android:layout_height="fill_parent" 
            	android:src="@drawable/img_memory" 
            	android:layout_centerInParent="true" 
            />
            <TextView 
            	android:textSize="30dp" 
            	android:id="@id/tx_memory" 
            	android:layout_width="wrap_content" 
            	android:layout_height="wrap_content" 
            	android:layout_marginTop="160.0dip" 
            	android:text="@string/str_memory" 
            	android:layout_centerHorizontal="true" 
            />
			
		</com.amlogic.mediaboxlauncher.MyRelativeLayout>
[/quote] 选中后,是下面变大,那前面还要显示不? 不显示就隐了,显示,就在变大后,再把include的布局bringtofront一下看看,不知道你的操作和最张效果要怎么样,总是,肯定是可以实现的。[/quote] 总之,很感谢你对我的帮助
头发还没秃a 2015-06-19
  • 打赏
  • 举报
回复
引用 15 楼 dalor 的回复:
[quote=引用 13 楼 zhumj_zhumj 的回复:] [quote=引用 10 楼 dalor 的回复:] 你再调整一下吧,是可以的,include相关属性设置一下,显示在最上层,不会扰乱别的布局的。
刚进入桌面的时候确实是显示在最上层的,但是当处于选中状态之后就会被主布局里面的控件给挡住,选中之后会有个按钮变大操作,是选的下面代码的控件来进行的:

<com.amlogic.mediaboxlauncher.MyRelativeLayout
			android:id="@+id/layout_memory"
		    android:layout_width="247dp"
		    android:layout_height="220dp"
		    android:layout_marginTop="40dp"
		   	android:layout_marginLeft="760dp"
		    android:focusable="true"
		    android:focusableInTouchMode="true"
			android:descendantFocusability="afterDescendants"	
			>
    
	    	<ImageView 
            	android:id="@id/img_memory" 
            	android:layout_width="fill_parent" 
            	android:layout_height="fill_parent" 
            	android:src="@drawable/img_memory" 
            	android:layout_centerInParent="true" 
            />
            <TextView 
            	android:textSize="30dp" 
            	android:id="@id/tx_memory" 
            	android:layout_width="wrap_content" 
            	android:layout_height="wrap_content" 
            	android:layout_marginTop="160.0dip" 
            	android:text="@string/str_memory" 
            	android:layout_centerHorizontal="true" 
            />
			
		</com.amlogic.mediaboxlauncher.MyRelativeLayout>
[/quote] 选中后,是下面变大,那前面还要显示不? 不显示就隐了,显示,就在变大后,再把include的布局bringtofront一下看看,不知道你的操作和最张效果要怎么样,总是,肯定是可以实现的。[/quote] 我想要做的效果是layout_memory.xml一直都显示在最上层,不管是选中状态还是没选中状态
开发者_android 2015-06-19
  • 打赏
  • 举报
回复
引用 13 楼 zhumj_zhumj 的回复:
[quote=引用 10 楼 dalor 的回复:] 你再调整一下吧,是可以的,include相关属性设置一下,显示在最上层,不会扰乱别的布局的。
刚进入桌面的时候确实是显示在最上层的,但是当处于选中状态之后就会被主布局里面的控件给挡住,选中之后会有个按钮变大操作,是选的下面代码的控件来进行的:

<com.amlogic.mediaboxlauncher.MyRelativeLayout
			android:id="@+id/layout_memory"
		    android:layout_width="247dp"
		    android:layout_height="220dp"
		    android:layout_marginTop="40dp"
		   	android:layout_marginLeft="760dp"
		    android:focusable="true"
		    android:focusableInTouchMode="true"
			android:descendantFocusability="afterDescendants"	
			>
    
	    	<ImageView 
            	android:id="@id/img_memory" 
            	android:layout_width="fill_parent" 
            	android:layout_height="fill_parent" 
            	android:src="@drawable/img_memory" 
            	android:layout_centerInParent="true" 
            />
            <TextView 
            	android:textSize="30dp" 
            	android:id="@id/tx_memory" 
            	android:layout_width="wrap_content" 
            	android:layout_height="wrap_content" 
            	android:layout_marginTop="160.0dip" 
            	android:text="@string/str_memory" 
            	android:layout_centerHorizontal="true" 
            />
			
		</com.amlogic.mediaboxlauncher.MyRelativeLayout>
[/quote] 选中后,是下面变大,那前面还要显示不? 不显示就隐了,显示,就在变大后,再把include的布局bringtofront一下看看,不知道你的操作和最张效果要怎么样,总是,肯定是可以实现的。
头发还没秃a 2015-06-19
  • 打赏
  • 举报
回复
引用 12 楼 dalor 的回复:
[quote=引用 9 楼 zhumj_zhumj 的回复:] [quote=引用 7 楼 dalor 的回复:] 这个的id这样命名,是不对的吧。
这个是没问题的,随便取什么名称都可以的啦。[/quote] 如果这两个是新增的,应该用+,如果你是引用已经存在的,那就没有+。不知道你的情况,我个人理解,这里是创建新。[/quote] 这不是新增的,是主布局一开始就存在的,需要使用它来进行按钮选中之后放大缩小的现象
头发还没秃a 2015-06-19
  • 打赏
  • 举报
回复
引用 10 楼 dalor 的回复:
你再调整一下吧,是可以的,include相关属性设置一下,显示在最上层,不会扰乱别的布局的。
刚进入桌面的时候确实是显示在最上层的,但是当处于选中状态之后就会被主布局里面的控件给挡住,选中之后会有个按钮变大操作,是选的下面代码的控件来进行的:

<com.amlogic.mediaboxlauncher.MyRelativeLayout
			android:id="@+id/layout_memory"
		    android:layout_width="247dp"
		    android:layout_height="220dp"
		    android:layout_marginTop="40dp"
		   	android:layout_marginLeft="760dp"
		    android:focusable="true"
		    android:focusableInTouchMode="true"
			android:descendantFocusability="afterDescendants"	
			>
    
	    	<ImageView 
            	android:id="@id/img_memory" 
            	android:layout_width="fill_parent" 
            	android:layout_height="fill_parent" 
            	android:src="@drawable/img_memory" 
            	android:layout_centerInParent="true" 
            />
            <TextView 
            	android:textSize="30dp" 
            	android:id="@id/tx_memory" 
            	android:layout_width="wrap_content" 
            	android:layout_height="wrap_content" 
            	android:layout_marginTop="160.0dip" 
            	android:text="@string/str_memory" 
            	android:layout_centerHorizontal="true" 
            />
			
		</com.amlogic.mediaboxlauncher.MyRelativeLayout>
开发者_android 2015-06-19
  • 打赏
  • 举报
回复
引用 9 楼 zhumj_zhumj 的回复:
[quote=引用 7 楼 dalor 的回复:] 这个的id这样命名,是不对的吧。
这个是没问题的,随便取什么名称都可以的啦。[/quote] 如果这两个是新增的,应该用+,如果你是引用已经存在的,那就没有+。不知道你的情况,我个人理解,这里是创建新。
开发者_android 2015-06-19
  • 打赏
  • 举报
回复
你再调整一下吧,是可以的,include相关属性设置一下,显示在最上层,不会扰乱别的布局的。
头发还没秃a 2015-06-19
  • 打赏
  • 举报
回复
引用 7 楼 dalor 的回复:
这个的id这样命名,是不对的吧。
这个是没问题的,随便取什么名称都可以的啦。
开发者_android 2015-06-19
  • 打赏
  • 举报
回复
还有下面的textview
开发者_android 2015-06-19
  • 打赏
  • 举报
回复
这个的id这样命名,是不对的吧。
头发还没秃a 2015-06-19
  • 打赏
  • 举报
回复
引用 5 楼 dalor 的回复:
具体需求,具体对待。如果布局不是太复杂,贴一下。
主布局代码如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@+id/layout_rect_group"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

	<RelativeLayout
		android:id="@+id/layout_up"
	    android:layout_width="1047dp"
	    android:layout_height="300dp"
	    android:layout_marginTop="56dp"
	    android:layout_centerHorizontal="true" 
	>
				
		<com.amlogic.mediaboxlauncher.MyRelativeLayout
			android:id="@+id/layout_setting"
		    android:layout_width="297dp"
			android:layout_height="220dp"
		    android:layout_marginTop="40dp"
			android:layout_marginLeft="710dp"
		    android:focusable="true"
		    android:focusableInTouchMode="true"
			android:descendantFocusability="beforeDescendants"	

		>	
			<ImageView
				android:id="@+id/img_setting"
		        android:layout_width="match_parent"
		        android:layout_height="match_parent"
		        android:src="@drawable/img_setting"
		        android:layout_centerInParent="true"
			/>
			<TextView
				android:id="@+id/tx_setting"
		        android:layout_width="wrap_content"
		        android:layout_height="wrap_content"
		        android:layout_marginTop="155dp"
		        android:layout_centerHorizontal="true"
		        android:text="@string/str_setting"
		        android:textSize="30dp"
			/>		
		</com.amlogic.mediaboxlauncher.MyRelativeLayout>

	</RelativeLayout>


	<RelativeLayout
	    android:layout_width="1047dp"
	    android:layout_height="300dp"
	    android:layout_marginTop="276dp"
	    android:layout_centerHorizontal="true" 
	    android:id="@+id/layout_down"
	>

		<com.amlogic.mediaboxlauncher.MyRelativeLayout
			android:id="@+id/layout_memory"
		        android:layout_width="247dp"
		        android:layout_height="220dp"
		        android:layout_marginTop="40dp"
		   	android:layout_marginLeft="760dp"
		        android:focusable="true"
		        android:focusableInTouchMode="true"
		        android:descendantFocusability="afterDescendants"	
		        >
    
	    	        <ImageView 
            	             android:id="@id/img_memory" 
            	             android:layout_width="fill_parent" 
            	             android:layout_height="fill_parent" 
            	             android:src="@drawable/img_memory" 
            	             android:layout_centerInParent="true" 
                             />
                        <TextView 
            	             android:textSize="30dp" 
            	             android:id="@id/tx_memory" 
            	             android:layout_width="wrap_content" 
            	             android:layout_height="wrap_content" 
            	             android:layout_marginTop="160.0dip" 
            	             android:text="@string/str_memory" 
            	             android:layout_centerHorizontal="true" 
                             />
			
		</com.amlogic.mediaboxlauncher.MyRelativeLayout>
		
	</RelativeLayout>

	<include
		layout="@layout/layout_memory"
	/>
	    
</RelativeLayout>
开发者_android 2015-06-19
  • 打赏
  • 举报
回复
具体需求,具体对待。如果布局不是太复杂,贴一下。
开发者_android 2015-06-19
  • 打赏
  • 举报
回复
引用 3 楼 zhumj_zhumj 的回复:
[quote=引用 2 楼 dalor 的回复:] [quote=引用 1 楼 dalor 的回复:] include中要设置大小,在layout_main中,布局是相对布局,include放在最后,设置include属性width和height都是fill_parent,就ok了。
为了防止后面有点击事件传递,给它设置一个可点击。[/quote] 楼上的办法不行了,加了属性width和height之后,layout_memory.xml里面的布局都变了,而且也不能让layout_memory.xml一直显示在最上层[/quote] 那只能说,你这个布局不是放在main最外层父布局中。
头发还没秃a 2015-06-19
  • 打赏
  • 举报
回复
引用 2 楼 dalor 的回复:
[quote=引用 1 楼 dalor 的回复:] include中要设置大小,在layout_main中,布局是相对布局,include放在最后,设置include属性width和height都是fill_parent,就ok了。
为了防止后面有点击事件传递,给它设置一个可点击。[/quote] 楼上的办法不行了,加了属性width和height之后,layout_memory.xml里面的布局都变了,而且也不能让layout_memory.xml一直显示在最上层
开发者_android 2015-06-19
  • 打赏
  • 举报
回复
引用 1 楼 dalor 的回复:
include中要设置大小,在layout_main中,布局是相对布局,include放在最后,设置include属性width和height都是fill_parent,就ok了。
为了防止后面有点击事件传递,给它设置一个可点击。
开发者_android 2015-06-19
  • 打赏
  • 举报
回复
include中要设置大小,在layout_main中,布局是相对布局,include放在最后,设置include属性width和height都是fill_parent,就ok了。

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧