我正在开发Android v2.2应用程序.
我有Fragment
英镑.在我的fragment类的onCreateView(...)
回调中,我对该片段展开了一个布局,如下所示:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.login, null);
return view;
}
上面的布局文件是(login.xml):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Username" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Username" />
</LinearLayout>
我想为上面的<LinearLayout>
元素设置一个paddingTop
,我想在Java代码中执行它,而不是在xml中执行它.
如何在我的片段Java类代码中将paddingTop
设置为<LinearLayout>
??