我有以下佈局文件:如何刪除默認佈局的填充/保證金
activity_main.xml中
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/frame_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="0px"
android:layout_marginRight="0px"
android:layout_marginTop="0px"
android:padding="0dp"
>
...
</FrameLayout>
和其他一些片段就像
fragment_init.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragmentInit"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp"
android:layout_marginTop="0px"
android:layout_marginLeft="0px"
android:layout_marginRight="0px"
android:background="#549F07"
>
<TextView
...
>
...
</RelativeLayout>
在Lint中一切看起來都很好,但是當我在Nexus 7 5.0.2上執行我的應用程序時,用顯示的填充或邊距可能爲10像素。
如何強制佈局不添加這些填充/緣上?
編輯:我要補充我如何插入我的片段。
Activiy
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
fragmentTransaction.replace(R.id.frame_container, new Fragment_init(), "Fragment_init").commit();
}
}
,我不使用任何夢詩任何地方...... THKS
它不應該顯示任何填充或邊距。什麼容器,你實際上取代你的片段的佈局?並且請不要使用像素 - 這在Android上不是很好的做法。 – Darwind 2015-03-31 09:35:50
您是否在使用res/values/dimens.xml中的任何內容 – Arlind 2015-03-31 09:38:43
順便說一句:您錯過了底部邊距。並且不要使用'px'單位。 – 2015-03-31 09:38:46