Android圆角布局错误
作者:互联网
我尝试创建不具有透明度的全屏活动并使用此布局XML:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/containerPageContainer">
<FrameLayout
android:id="@+id/informationContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" >
<LinearLayout
android:id="@+id/myContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:background="@drawable/rounder_corners"
android:orientation="vertical"
android:padding="10dp" >
</LinearLayout>
</FrameLayout>
</merge>
对于圆角:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#FFFFFFFF" />
<corners android:radius="10dp" />
</shape>
但是在角落,底部和顶部都有这样的结果:
请帮我解决一下.
解决方法:
我找到了解决方案:
1)在res / values /中创建主题XML:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
2)圆角样式drawable / rounded_corners.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#FFFFFFFF" />
<corners android:radius="10dp" />
</shape>
3)活动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="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/qrCodeContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:background="@drawable/rounder_corners"
android:orientation="vertical"
android:padding="15dp"
android:layout_margin="6dp" >
</RelativeLayout>
</RelativeLayout>
4)描述项目清单XML中的活动:
<activity
android:name=".view.ViewCodeActivity"
android:label="@string/app_name"
android:theme="@style/Theme.Transparent">
</activity>
标签:android,android-layout,layout,rounded-corners 来源: https://codeday.me/bug/20190529/1181399.html