手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >关于布局的圆角问题,写了之后没有效果
关于布局的圆角问题,写了之后没有效果
摘要:今天遇到了一个关于圆角布局的问题,以下是两个xml,第一个写法添加了pading,如下所示真个是能显示圆角的,但是问题出现了,如截图所示,两...

今天遇到了一个关于圆角布局的问题,以下是两个xml,第一个写法添加了pading,如下所示

< ?xml version="1.0" encoding="utf-8"? >
< shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle" >

    < solid
        android:color="@color/qianlan"/ >

    < padding
        android:left="10dp"
        android:right="10dp"/ >

    < corners
        android:bottomLeftRadius="10dp"
        android:bottomRightRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp"/ >
< /shape >

真个是能显示圆角的,但是问题出现了,如截图所示,两边变得很难看,改成上下效果也只是变成上下有蓝条,也是很难看

关于布局的圆角问题,写了之后没有效果0

第二种是我自己又重新做了一个测试的,随意写了一个Relativelaout,效果是可以显示圆角,并且没有边框那些难看的东西

< ?xml version="1.0" encoding="utf-8"? >
< shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle" >
    < solid
        android:color="@color/colorAccent"/ >
    < corners
        android:bottomLeftRadius="10dp"
        android:bottomRightRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp"/ >
< /shape >

但是用到自己写的布局的时候,就没有一点效果了。以下是我需要改变布局的XML

< ?xml version="1.0" encoding="utf-8"? >
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/activity_person_track_view"
    android:gravity="center_vertical|center_horizontal"
    tools:context="com.example.administrator.qinghuayuan.person.PersonTrackActivity"
     >
    < RelativeLayout(就是这一个)
        android:onClick="false"
        android:layout_width="@dimen/DIMEN_360PX"
        android:layout_height="@dimen/DIMEN_600PX"
        android:gravity="center"
        android:background="@drawable/track_background"
        >
      < Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/track_background"/ >
   < LinearLayout
       android:layout_width="match_parent"
       android:layout_height="@dimen/DIMEN_700PX"
       android:background="@color/lightwhite"
       android:orientation="vertical" >
       < TextView
           android:layout_width="match_parent"
           android:layout_height="@dimen/DIMEN_40PX"
           android:textSize="@dimen/DIMEN_18PX"
           android:textColor="@color/lightwhite"
           android:text="物流跟踪"
           android:background="@color/qianlan"
           android:gravity="center_vertical|center"/ >
       < RelativeLayout
           android:layout_width="match_parent"
           android:layout_height="@dimen/DIMEN_80PX"
           android:background="@color/qianlan"
           android:padding="@dimen/DIMEN_10PX"
            >
           < ImageView
               android:layout_width="@dimen/DIMEN_60PX"
               android:layout_height="match_parent"
               android:background="@drawable/yaopin"
               android:id="@+id/imageView2"
               android:layout_alignParentTop="true"
               android:layout_alignParentLeft="true"
               android:layout_alignParentStart="true" / >
           < LinearLayout
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:orientation="vertical"
               android:id="@+id/linearLayout"
               android:layout_toLeftOf="@+id/imageView3"
               android:layout_toRightOf="@+id/imageView2"
               android:layout_toEndOf="@+id/imageView2" >
               < TextView
                   android:layout_width="match_parent"
                   android:layout_height="@dimen/DIMEN_18PX"
                   android:textColor="@color/lightwhite"
                   android:textSize="@dimen/DIMEN_14PX"
                   android:text="食了消食了消食了消食了消"
                   android:paddingLeft="@dimen/DIMEN_10PX"/ >
               < TextView
                   android:layout_width="match_parent"
                   android:layout_height="@dimen/DIMEN_18PX"
                   android:text="单号查询:1005456655555544555"
                   android:textSize="@dimen/DIMEN_12PX"
                   android:textColor="@color/lightwhite"
                   android:layout_gravity="center_vertical"
                   android:paddingLeft="@dimen/DIMEN_10PX"/ >
               < TextView
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:text="预计明天送达"
                   android:textSize="@dimen/DIMEN_14PX"
                   android:gravity="center_vertical"
                   android:paddingLeft="@dimen/DIMEN_10PX"
                   android:textColor="@color/lightwhite"/ >
           < /LinearLayout >
           < Button
               android:background="@drawable/right_blue"
               android:layout_width="@dimen/DIMEN_20PX"
               android:layout_height="match_parent"
               android:layout_alignParentRight="true"
               android:id="@+id/imageView3" / >
       < /RelativeLayout >
       < ListView
           android:id="@+id/person_track_listview"
           android:layout_width="match_parent"
           android:layout_weight="1"
           android:layout_height="match_parent"
            >
       < /ListView >
       < RelativeLayout
           android:layout_width="match_parent"
           android:layout_height="@dimen/DIMEN_40PX" >
           < Button
               android:layout_width="@dimen/DIMEN_80PX"
               android:layout_height="@dimen/DIMEN_40PX"
               android:text="物流客服"
               android:textSize="@dimen/DIMEN_14PX"
               android:textColor="@color/black"
               android:background="@drawable/button_track_style"
               android:layout_marginRight="@dimen/DIMEN_18PX"
               android:layout_marginEnd="@dimen/DIMEN_18PX"
               android:layout_centerVertical="true"
               android:layout_alignParentRight="true"
               android:layout_alignParentEnd="true" / >
       < /RelativeLayout >
       < TextView
           android:layout_width="match_parent"
           android:layout_height="@dimen/DIMEN_1PX"
           android:background="@color/dise"/ >
       < TextView
           android:layout_width="match_parent"
           android:layout_height="@dimen/DIMEN_50PX"
           android:background="@color/lightwhite"/ >
   < /LinearLayout >
    < /RelativeLayout >
< /RelativeLayout >

需要添加圆角的布局我标注了一下,还有就是,这个界面从最上面的图片可以看出,我把它做成了悬浮窗口,实在是搞不明白,应该和悬浮不悬浮没关系,因为第一种方法就可以,但是有蓝条,但是第二种一点反应都没有,求各位大佬们帮帮忙,实在是想不明白了,在这里先谢过了

回复讨论(解决方案)

一点反应都没有,这个问题应该是你没有设置监听啊 实在话,没看懂你的问题究竟是要干嘛 实在话,没看懂你的问题究竟是要干嘛

其实就是给这个悬浮的布局做一个圆角,但是第二种在这里面用不了。第一种又有问题。所以我想问的是,是不是我的布局有问题,或者是别的什么 一点反应都没有,这个问题应该是你没有设置监听啊

不不不,我说的没反应是没有圆角的效果,并不是监听什么的,监听和点击一切正常,就是想加个圆角

实在话,没看懂你的问题究竟是要干嘛

其实就是给这个悬浮的布局做一个圆角,但是第二种在这里面用不了。第一种又有问题。所以我想问的是,是不是我的布局有问题,或者是别的什么 第一种说的两边变得好难看是指什么?

实在话,没看懂你的问题究竟是要干嘛

其实就是给这个悬浮的布局做一个圆角,但是第二种在这里面用不了。第一种又有问题。所以我想问的是,是不是我的布局有问题,或者是别的什么 第一种说的两边变得好难看是指什么? 额,就截图里面的,两边有两道蓝色的,正常来说应该只有圆角才对,第一种方法我觉得不行

实在话,没看懂你的问题究竟是要干嘛

其实就是给这个悬浮的布局做一个圆角,但是第二种在这里面用不了。第一种又有问题。所以我想问的是,是不是我的布局有问题,或者是别的什么 第一种说的两边变得好难看是指什么? 多谢回复

实在话,没看懂你的问题究竟是要干嘛

其实就是给这个悬浮的布局做一个圆角,但是第二种在这里面用不了。第一种又有问题。所以我想问的是,是不是我的布局有问题,或者是别的什么 第一种说的两边变得好难看是指什么? 多谢回复

http://blog.csdn.net/sam0750/article/details/53465693

实在话,没看懂你的问题究竟是要干嘛

其实就是给这个悬浮的布局做一个圆角,但是第二种在这里面用不了。第一种又有问题。所以我想问的是,是不是我的布局有问题,或者是别的什么 第一种说的两边变得好难看是指什么? 多谢回复

http://blog.csdn.net/sam0750/article/details/53465693

不行啊,我这个是用Activity变成的Dialog,那个不能适用啊

实在话,没看懂你的问题究竟是要干嘛

其实就是给这个悬浮的布局做一个圆角,但是第二种在这里面用不了。第一种又有问题。所以我想问的是,是不是我的布局有问题,或者是别的什么 第一种说的两边变得好难看是指什么? 多谢回复

http://blog.csdn.net/sam0750/article/details/53465693

已经解决了,主要原因就是我上面的布局太多,导致有些布局把圆角覆盖掉了,多谢你的回复,谢谢

【关于布局的圆角问题,写了之后没有效果】相关文章:

Android中的Button自定义点击效果实例代码

Android 系统有浏览记录搜索框

Android绑定添加了注解的控件,及其事件方法

html5在android中的使用问题及技巧解读

操作SD卡中文件夹和文件的方法

android 设置圆角图片实现代码

移动端WebApp隐藏地址栏的方法

android 实现圆角图片解决方案

android 电话状态监听(来电和去电)实现代码

Android实现TextView中文字链接的4种方式介绍及代码

精品推荐
分类导航