【发布时间】:2017-03-17 23:08:58
【问题描述】:
我正在使用compile 'com.intuit.sdp:sdp-android:1.0.3' api 来设置这样的线性布局的边距
<LinearLayout
android:id="@+id/layout_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/_10sdp"
android:layout_marginTop="@dimen/_10sdp"
android:padding="@dimen/_8sdp"
android:orientation="vertical">
</LinearLayout>
现在,当我以编程方式更改边距时,它会在 dp 而不是 sdp 中更改它
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, 10, 10, 0);
layout_message.setLayoutParams(params);
那么如何根据 sdp 以编程方式更改边距?谢谢
【问题讨论】:
-
你为什么要使用这个 sdp?
-
它为不同的屏幕尺寸隐式调整您的应用布局设计,这意味着如果您使用 sdp 为移动设备构建应用程序,那么平板设备屏幕上会出现相同的设计尺寸,您不会需要明确执行。