请告诉我如何使这张照片占据整个屏幕,无论屏幕的方向或尺寸如何。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
tools:context="com.gadgetcatch.alex.cardcelebration.MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/background" />
</RelativeLayout>
</ScrollView>
以上图片均为Nexus4和Nexus 10,没有任何属性。在nexus 10上,图像在主图像中不均匀,它在之后开始。
添加adjustViewBounds =“true”确实使图片与屏幕一样宽,但仍然在Nexus 10设备的底部留下空白条带
必须使用什么属性,以便无论使用何种设备,图片都将占据整个屏幕。提前感谢任何可以提供帮助的人
答案 0 :(得分:0)
添加struct Proxy
{
std::vector<const abc*> values;
operator abc() {
assert(values.size() > 2);
abc result = *(values.back()); // Can't avoid one copy.
values.pop_back();
for (const auto& v : values)
for (const auto& key_value : v->data)
result.data[key_value.first] += key_value.second;
return result;
}
};
Proxy operator +(const abc &lhs, const abc& rhs) {
Proxy result;
result.values.push_back(&lhs);
result.values.push_back(&rhs);
return result;
}
Proxy operator +(Proxy lhs, const abc& rhs) {
lhs.values.push_back(&rhs);
}
Proxy operator +(const abc& lhs, Proxy rhs) {
rhs.values.push_back(&lhs);
}
Proxy operator +(Proxy lhs, const Proxy& rhs) {
// implementation left as an exercise for the reader.
}
无论如何,图像都将填满整个屏幕,但两侧可能会被裁剪掉。
答案 1 :(得分:0)
除非相对布局占据整个屏幕,否则您将始终在底部获得白色条带,因为图像视图上的匹配父属性。
这就是我要做的事情:
所以,结构将如下所示:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.gadgetcatch.alex.cardcelebration.MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/background"
android:scaleType="centerCrop" />
<ScrollView
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RelativeLayout>
</ScrollView>
</FrameLayout>
我忘了添加,使用这种方法图像不会滚动,它将始终覆盖整个屏幕。