gpt4 book ai didi

android - Imageview 不应用 fitSystemWindows

转载 作者:行者123 更新时间:2023-11-29 20:11:05 26 4
gpt4 key购买 nike

我需要图像显示在状态栏下方(状态栏必须是透明的,不知道怎么做)但我无法让它工作,我已经尝试了很多布局示例。
这是我的 xml 布局:

<RelativeLayout 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"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activities.FullScreenPlayer">

<com.intaj.sawt.customviews.SquareImageView
android:id="@+id/imgViewCover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/cover_holder" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/imgViewCover"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/full_screen_player_bg"
android:orientation="vertical"
android:padding="5dp">

<TextView
android:id="@+id/txtSongTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textAppearance="@android:style/TextAppearance.Medium"
android:textStyle="bold" />

<TextView
android:id="@+id/txtArtistName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textAppearance="@android:style/TextAppearance.Medium" />

</LinearLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp">

<TextView
android:id="@+id/startText"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:gravity="center_vertical"
android:maxLines="1"
android:textColor="@android:color/white" />

<SeekBar
android:id="@+id/seekBar1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_toEndOf="@+id/startText"
android:layout_toLeftOf="@+id/endText"
android:layout_toRightOf="@+id/startText"
android:layout_toStartOf="@+id/endText" />

<TextView
android:id="@+id/endText"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignWithParentIfMissing="true"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:gravity="center_vertical"
android:maxLines="1"
android:textColor="@android:color/white" />

</RelativeLayout>

<LinearLayout
android:id="@+id/layoutPlaybackControls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">

<ImageView
android:id="@+id/repeat"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_action_repeat"
android:tint="@color/colorAccent" />

<ImageView
android:id="@+id/prev"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_skip_previous_white_48dp"
android:tint="@color/colorAccent" />

<ImageView
android:id="@+id/playPause"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_weight="1"
android:src="@drawable/ic_play_arrow_white_48dp"
android:tint="@color/colorAccent" />

<ImageView
android:id="@+id/next"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_skip_next_white_48dp"
android:tint="@color/colorAccent" />

<ImageView
android:id="@+id/shuffle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_action_shuffle"
android:tint="@color/colorAccent" />

</LinearLayout>

</LinearLayout>

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

<com.pnikosis.materialishprogress.ProgressWheel
android:id="@+id/progressBar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:visibility="invisible"
wheel:matProg_barColor="@color/colorAccentSettings"
wheel:matProg_progressIndeterminate="true" />

结果是这样的:
如您所见,状态栏没有变得透明,或者图像不在其下方。

enter image description here

我发布我的风格:

样式.xml

<style name="AppTheme" parent="AppTheme.Light" />
<!--<style name="AppThemeDark" parent="AppTheme.Dark" />-->

<style name="AppTheme.Light" parent="Theme.AppCompat.Light.NoActionBar">
<!--light-->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@color/textPrimaryColor</item>
<item name="android:textColorSecondary">@color/colorPrimaryDark</item>
<item name="android:windowBackground">@color/windowBackground</item>
</style>

样式.xml(v21)

 <style name="AppTheme" parent="AppTheme.Light">
<item name="android:windowTranslucentStatus">true</item>
<!--<item name="android:statusBarColor">@android:color/transparent</item>-->
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>

请帮忙!!

最佳答案

try this

  <RelativeLayout 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"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activities.FullScreenPlayer">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

<com.intaj.sawt.customviews.SquareImageView
android:id="@+id/imgViewCover"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:layout_below="@id/toolbar"
android:scaleType="centerCrop"
android:src="@drawable/cover_holder" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/imgViewCover"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/full_screen_player_bg"
android:orientation="vertical"
android:padding="5dp" >

<TextView
android:id="@+id/txtSongTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textAppearance="@android:style/TextAppearance.Medium"
android:textStyle="bold" />

<TextView
android:id="@+id/txtArtistName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textAppearance="@android:style/TextAppearance.Medium" />
</LinearLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp" >

<TextView
android:id="@+id/startText"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:gravity="center_vertical"
android:maxLines="1"
android:textColor="@android:color/white" />

<SeekBar
android:id="@+id/seekBar1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_toEndOf="@+id/startText"
android:layout_toLeftOf="@+id/endText"
android:layout_toRightOf="@+id/startText"
android:layout_toStartOf="@+id/endText" />

<TextView
android:id="@+id/endText"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignWithParentIfMissing="true"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:gravity="center_vertical"
android:maxLines="1"
android:textColor="@android:color/white" />
</RelativeLayout>

<LinearLayout
android:id="@+id/layoutPlaybackControls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp" >

<ImageView
android:id="@+id/repeat"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_action_repeat"
android:tint="@color/colorAccent" />

<ImageView
android:id="@+id/prev"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_skip_previous_white_48dp"
android:tint="@color/colorAccent" />

<ImageView
android:id="@+id/playPause"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_weight="1"
android:src="@drawable/ic_play_arrow_white_48dp"
android:tint="@color/colorAccent" />

<ImageView
android:id="@+id/next"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_skip_next_white_48dp"
android:tint="@color/colorAccent" />

<ImageView
android:id="@+id/shuffle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_action_shuffle"
android:tint="@color/colorAccent" />
</LinearLayout>
</LinearLayout>

<com.pnikosis.materialishprogress.ProgressWheel
android:id="@+id/progressBar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:visibility="invisible"
wheel:matProg_barColor="@color/colorAccentSettings"
wheel:matProg_progressIndeterminate="true" />

</RelativeLayout>

关于android - Imageview 不应用 fitSystemWindows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34908013/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com