所以我有一個圖像視圖和下面的相對佈局。期望的是始終讓用戶看到嵌套佈局中的文本視圖和按鈕。圖像是頂部圖像(不是全屏幕背景),但是有些圖像的背景稍微偏離圖像視圖。我已經嘗試了不同的圖像規模類型和不同的佈局完全(幀,所有的線性,等。)android佈局留下小缺口
和一些代碼
https://gist.github.com/whatkai/92f66d2322957d86dd3fe28a9a5d03c0
FYI佈局權重留下的空白太。
所以我有一個圖像視圖和下面的相對佈局。期望的是始終讓用戶看到嵌套佈局中的文本視圖和按鈕。圖像是頂部圖像(不是全屏幕背景),但是有些圖像的背景稍微偏離圖像視圖。我已經嘗試了不同的圖像規模類型和不同的佈局完全(幀,所有的線性,等。)android佈局留下小缺口
和一些代碼
https://gist.github.com/whatkai/92f66d2322957d86dd3fe28a9a5d03c0
FYI佈局權重留下的空白太。
有太多的方法來做到這一點。 嘗試使用的LinearLayout這個解決方案(方向:垂直):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/REFragment"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@color/accidentAssistanceColor">
<ImageView
android:id="@+id/SettingsImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/app_name"
android:scaleType="fitXY"
android:src="@drawable/ers"
android:layout_weight="1"/>
<LinearLayout
android:background="@color/appStartERSBackground"
android:layout_centerHorizontal="true"
android:id="@+id/onView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/SettingsImage"
android:gravity="bottom|clip_vertical|center"
android:orientation="vertical">
<Button
android:gravity="bottom|end"
android:layout_centerHorizontal="true"
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/transparent"
android:text="Not Now"
android:textColor="@color/white"/>
<Button
android:id="@+id/button2"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/button"
android:text="approve"
android:textColor="@color/white"/>
<TextView
android:gravity="center_horizontal|center_vertical"
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/button2"
android:layout_gravity="center"
android:text="BLdfdsAH"
android:textColor="@color/white"/>
<TextView
android:gravity="center_horizontal|center_vertical"
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="BLAH"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
並回答你關於如何SCALL你的形象,我用的android:scaleType fitXY尊重比ASPET。
如果您希望瞭解每一個scallType是如何工作的,請參閱以下鏈接:你的形象和佈局之間 https://robots.thoughtbot.com/android-imageview-scaletype-a-visual-guide
集視圖標籤。 是這樣的。
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000000" />
這與我的第一次嘗試類似,但它仍然給我的設備一個小差距?不知道爲什麼佈局似乎沒有適當的位置 – h4mme7
請問您可以加入您需要的屏幕截圖嗎? –