最近、私は問題で唖然としました。私のアンドロイドでは、同じ仰角のリストまたはスクロールビューの電話要素は、その配置に関連して異なる影を持っています。例えば、画面の上部にのビューは、画面の下部にのビューが表示されるたびに小さな光の影を持っていますは、より暗くて強い影を持っています。ここではGoogleからのスクリーンショットは、アプリケーションをキープです:同じビューの高さは、上面図と下面図で異なって見えます
だから、私はこれが原因で正確にGoogleキープアプリケーションであることを考えました。たぶん、Googleからの人たちは、そのアプリケーションのための陰影でそのトリックをすることにしました。したがって、サンプルアプリケーションを作成しました。
マイレイアウト:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
</LinearLayout>
私のスタイル:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppButton">
<item name="android:background">@color/colorAccent</item>
<item name="android:elevation">4dp</item>
<item name="android:gravity">center</item>
<item name="android:padding">16dp</item>
<item name="android:textColor">@android:color/white</item>
</style>
</resources>
、出力は次のとおりです。
ご覧のとおり、同じ効果があります(上の図は小さな影、下の図は大きな影)。だから私の質問は:
- 私は間違っていましたか?
- どのようにすべてのビュー(位置によって異なる)で同じ影を達成できますか?
- また、私はドキュメントで何の説明も見つけられていないので、どこでその現象について読むことができますか?
- すべてのデバイスで、または特定のデバイスでのみ発生しますか?
P.S:私はネクサス5X、アンドロイド7.1.2を持っています。
UPD: 重要な言葉は、Android Studioのプレビューウィンドウからすべて正常です。すべてのビューは他のビューと同じ影を持ちます。しかし、実際のデバイスでは、違いを見ることができます。
は、影が一番下にあります。 https://material.io/guidelines/components/cards.html# https://material.io/guidelines/material-design/elevation-shadows.html#elevation-shadows-shadows – tyczj
@tyczj実際には、私は持っているあなたの説明と私たちが異なることについて話すことに気づいた。すべてのシャドウは上から下にキャストされますが、リストのトップビューとリストの最下部のビューを見ると、そのシャドウは異なりますが、どちらのビューも 'elevation = 4dp'になります。しかし、ユーザーにとっては、画面上部のビューは2-3dpの標高を持ち、画面下部のビューは4-5dpの標高を持っているように見えます。 –