码迷,mamicode.com
首页 > 其他好文 > 详细

Fragment不占满父控件

时间:2014-10-19 23:15:06      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   http   color   io   ar   java   sp   

============问题描述============


bubuko.com,布布扣
图片如上,为什么fragment不占满整个content啊?
代码如下:
Action.java:
ft.replace(R.id.content, new NoteFragment());
fragment.java:
public class AllQuestionFragment extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.allquestion_ui,null);
return view;
allquestion_ui.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" 
    android:layout_weight="1">

    <TextView 
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:text="A"
     android:gravity="center"
     android:id="@+id/tv_fragment"
    />

</LinearLayout>

============解决方案1============


android:layout_weight="1"这行去掉

============解决方案2============


你activity的布局文件有问题

============解决方案3============


fragment是要放在你activity里的,在activity里有对fragment属性的设置,或者是fragment replace了activity里的某个view,因该查一下activity里的布局是不是match_parent

Fragment不占满父控件

标签:android   style   blog   http   color   io   ar   java   sp   

原文地址:http://www.cnblogs.com/llj1985522/p/4035726.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!