这是java
maintitle = (TextView)findViewById(R.id.text_particularlatestnewstitle);
maintitle.setPadding(100, 0, 0, 0);
Run Code Online (Sandbox Code Playgroud)
alllatestnewslist.xml这里
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_temp"
android:layout_width="fill_parent"
android:layout_height="100px"
android:background="@drawable/background_news_list" >
<ImageView
android:id="@+id/image_alllatestnewstitle"
android:layout_width="134px"
android:layout_height="80px"
android:layout_marginBottom="5px"
android:layout_marginLeft="10px"
android:layout_marginRight="10px"
android:layout_marginTop="5px"
android:scaleType="centerCrop" />
<LinearLayout
android:id="@+id/test"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5px"
android:layout_marginLeft="100px"
android:layout_marginRight="10px"
android:layout_marginTop="5px"
android:orientation="vertical" >
<TextView
android:id="@+id/text_particularlatestnewstitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="25px" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25px" >
<TextView
android:id="@+id/text_newsdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999999"
android:textSize="15px" />
<TextView
android:id="@+id/text_newscategorytitle"
android:layout_width="50px"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:gravity="right"
android:textColor="#ff0000"
android:textSize="15px" />
</RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在这个xml中,我有其他对象,如图像视图和textview等.
我这样设置,但它不会离开左边100 ........................
任何其他方式?????????????????????
而不是填充,更改边距.
编辑:在这里,让我为你做.
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(30, 20, 30, 0); // margins as you wish
TextView myTextView = findViewById(R.id.text_particularlatestnewstitle);
myTextView.setLayoutParams(layoutParams);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14412 次 |
| 最近记录: |