我的布局中有一个CardView,宽度为match_parent
。当我在我的Marshmallow测试设备中运行应用程序时,它的工作完美。但是在我的Jellybean设备中,它显示了一些填充。
我试过
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false"
android:hardwareAccelerated="true"
但它不起作用。
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wiinnova.cryptcoin">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".activities.ThisApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activities.HomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.ContainerActivity"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity
android:name=".activities.TransactionActivity"
android:label="@string/title_activity_transaction"
android:theme="@style/AppTheme"></activity>
</application>
</manifest>
片段布局:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f00"
android:orientation="vertical"
tools:context="com.wiinnova.cryptcoin.fragments.CoinsList_Frg">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:orientation="vertical">
<ProgressBar
android:id="@+id/pro_bar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="5dp"
android:foregroundGravity="center"
android:indeterminate="true"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#f00">
<android.support.v7.widget.CardView
android:id="@+id/main_top_card"
android:layout_width="match_parent"
android:layout_height="100dp"
android:hardwareAccelerated="true"
app:cardElevation="10dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/top_card_img"
android:gravity="center"
android:orientation="vertical"
android:padding="20dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Watchlist"
android:textColor="#fff"
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Evolution : Current"
android:textColor="#fff" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<com.baoyz.widget.PullRefreshLayout
android:id="@+id/coin_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:refreshColor="@color/colorPrimaryDark"
app:refreshType="material">
<android.support.v7.widget.RecyclerView
android:id="@+id/coins_list_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.baoyz.widget.PullRefreshLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:src="@drawable/ic_add"
app:elevation="10dp"
app:layout_anchor="@id/main_top_card"
app:layout_anchorGravity="bottom|right|end" />
</android.support.design.widget.CoordinatorLayout>
答案 0 :(得分:1)
降低xml中的cardview海拔大小
答案 1 :(得分:0)
您为所有设备和平板电脑使用了一个库来管理ui设计。
在gradle文件中添加以下依赖项...
compile 'com.intuit.sdp:sdp-android:1.0.4'
然后在以下代码方式定义任何填充,边距之后..
android:padding="@dimen/_20sdp"
android:layout_marginTop="@dimen/_5sdp"