6

Lollipop デバイスで見られるのと同じように、KitKat デバイスのツールバーに同じ上昇効果を表示したいと考えています。以下は、キットカット デバイスとロリポップ デバイスの両方のスクリーンショットです。このリンクを参照しましたが、問題はまだ解決していません。

ロリポップ デバイス:

ここに画像の説明を入力


キットカット デバイス:

ここに画像の説明を入力


ContentMain.xml

<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"
tools:context="com.global.market.checkinternet.MainActivity">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#fff"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />



</android.support.design.widget.AppBarLayout>
    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMode="scrollable"
        android:background="#3F51B5"
        style="@style/MyCustomTabLayout"
        app:tabTextColor="#ffffff"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"  />


</LinearLayout>


app_bar_main.xml

    <?xml version="1.0" encoding="utf-8"?>
<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"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:fitsSystemWindows="true"
    tools:context="com.global.market.MainActivity">

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



</android.support.design.widget.CoordinatorLayout>
4

1 に答える 1

0

前述のように、ロリポップ デバイスの下ではエレベーションを使用できませんが、これを行う別の方法はほとんどありません。

私は個人的にすべてを試しましたが、どれも機能しませんでしたが、プロジェクトのlayout-v19フォルダーにフォルダーを追加することで管理できました。resしたがって、それは特定のAPI-19 layoutになります。そこに、以下のリンクのように、またはその他の方法viewToolbar- AppbarLayout(デザインによって異なります) を追加できます。4dp height

https://github.com/vipulasri/Toolbar-Elevation-Pre-Lollipop

そしてこれ: https://mobikul.com/show-shadow-toolbar-api-21/

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar" />
    </android.support.design.widget.AppBarLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!--  Place Your Layout Here  -->

        <View
            android:id="@+id/shadow_view"
            android:layout_width="match_parent"
            android:layout_height="5dp"
            android:background="@drawable/dropshadow" />

    </FrameLayout>

</LinearLayout>

ドロップシャドウ.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <gradient android:startColor="@android:color/transparent"
        android:endColor="#60555555"
        android:angle="90"/>

</shape>

そして、java-kotlin側で、それが であるかどうかを確認し、API-19そこでレイアウトを膨らませます:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        v = inflator.inflate(R.layout.item_showdetail_asset_kitkat, this);
    } else {
        v = inflator.inflate(R.layout.item_showdetail_asset, this);
    } 

お役に立てれば。

于 2018-08-20T11:55:37.477 に答える