在不同的屏幕上使用不同的布局样式(Android)

在不同的屏幕上使用不同的布局样式(Android),android,layout,styles,Android,Layout,Styles,我有一些问题,我的布局在一个屏幕上,它没有很好地重新缩放,一些文本弹出的按钮等 我想解决这个问题,但我需要你的帮助 在我的XML中,我创建了: <style name="styleforS5" parent="android:style/Widget.ImageButton"> <item name="android:background">@null</item> <item name="android:layout_width">

我有一些问题,我的布局在一个屏幕上,它没有很好地重新缩放,一些文本弹出的按钮等

我想解决这个问题,但我需要你的帮助

在我的XML中,我创建了:

<style name="styleforS5" parent="android:style/Widget.ImageButton">
    <item name="android:background">@null</item>
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_weight">1.0</item>
    <item name="android:paddingTop">5dp</item>
    <item name="android:paddingBottom">5dp</item>
</style>

<style name="samsungTablet" parent="android:style/Widget.ImageButton">
    <item name="android:background">@null</item>
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_weight">2.0</item>
    <item name="android:paddingTop">15dp</item>
    <item name="android:paddingBottom">5dp</item>
</style>

@空的
包装内容
包装内容
1
5dp
5dp
@空的
包装内容
包装内容
2
15dp
5dp
现在我的问题是:如果输入是平板电脑,它应该使用三星平板电脑样式,如果是s5,它应该使用stylefors5,我该如何写

谢谢你的帮助,
Zak

也许解决方案是两台设备只有一种样式,但根据最小可用宽度在两个特定文件夹中定义(请参阅):

对于智能手机(S5):res/values/styles.xml

<style name="ImageButtonStyle" parent="android:style/Widget.ImageButton">
    <item name="android:background">@null</item>
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_weight">1.0</item>
    <item name="android:paddingTop">5dp</item>
    <item name="android:paddingBottom">5dp</item>
</style>

@空的
包装内容
包装内容
1
5dp
5dp
对于平板电脑:res/values-sw600dp/styles.xml

<style name="ImageButtonStyle" parent="android:style/Widget.ImageButton">
    <item name="android:background">@null</item>
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_weight">2.0</item>
    <item name="android:paddingTop">15dp</item>
    <item name="android:paddingBottom">5dp</item>
</style>

@空的
包装内容
包装内容
2
15dp
5dp

有了这些文件夹,Android系统将根据屏幕大小选择“正确”的样式。

答案肯定是——不要这样做。答案似乎需要对这一点和程序进行广泛的指导,以避免像这样接近它。我们提供了一个系统,在很大程度上消除了质疑。我已经尝试了很多修复方法。没用,所以在我看来这是最好的选择。我认为这确实是一个更好的解决办法。我会尝试一下,但我没有一个标准的values-sw600dp/styles目录,我应该手动创建还是?是的,你可以手动创建,或者如果你使用Android Studio,你可以创建一个新的Android资源目录并添加一个“最小屏幕宽度”限定符