I have problem with shadows. In Android Studio preview shows:
but in emulator and in the phone I see:
There is my xml:
<LinearLayout
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"
tools:context=".Profil"
android:background="@color/lightback"
android:orientation="vertical">
<FrameLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="30dp"
android:id="@+id/testFragmentu2"
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true"
android:translationZ="10dp"
android:background="@android:color/transparent"></FrameLayout>
<FrameLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="175dp"
android:id="@+id/testFragmentu"
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true"
android:translationZ="0dp"
android:background="@android:color/transparent"
android:layout_marginTop="10dp"></FrameLayout>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="150dp"
android:translationZ="10dp"
android:background="@android:color/transparent"
android:layout_marginTop="10dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right|top"
android:background="@android:color/transparent">
<TextView android:id="@id/android:empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Niestety, wszyscy mają partnerów na siłownię... :(" />
<ListView android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false" />
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
I am trying to create 3 fragments. Two of them should appear from top when I click on an item of third fragment. But there is no shadow. I've set translationZ
but it doesn't work...
For shadows, you should use elevation
like this :
app:elevation="10dp"
instead of translationZ
As mentioned in the android docs, elevation
is "base z depth of the view" and this is a static variable, while translationZ
is dynamic.
elevation
base z depth of the view.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
You should use translationZ
for animations.