2012-12-28 16 views
0

垂直的Android LinearLayout中不显示我正在做一个Android应用程序,我想做到这一切

info.xml

但现在它只显示照片和TextView的。

这是我的info.xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/linear1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

<LinearLayout 
    android:id="@+id/linear2" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal"> 

    <ImageView 
    android:id="@+id/image_profile" 
    android:layout_height="48dp" 
    android:layout_width="48dp" 
    android:layout_marginTop="15dp" 
    android:layout_marginLeft="20dp"/> 


    <TextView 
    android:id="@+id/nom_profile" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:layout_weight="1" 
    android:layout_marginTop="20dp" 
    android:layout_marginLeft="10dp"/> 

    </LinearLayout> 

    <TextView 
    android:id="@+id/SocialNetworks" 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    android:text="Redes Sociales" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:layout_weight="1"/> 


    <ListView 
    android:id="@+id/listaRedesSociales" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="4"> 
    </ListView> 

    </LinearLayout> 

我不知道为什么只显示我这个,我不知道为什么第一次的LinearLayout把horitzontal当我puted垂直! info.xml不刷新?或者编程不好?

有人可以帮我吗? match_parent *的

感谢

+2

cause2 linear2的layout_height是match_parent,它会占用所有垂直空间。尝试将layout_height的值更改为wrap_content – kingori

+0

我也会建议将父布局设置为RelativeLayout – Tobrun

回答

0

使用* FILL_PARENT instend,也许你应该改变linear2的高度:layout_height = 'WRAP_CONTENT'layout_height = “0dp” layout_weight = “1”

+0

“FILL_PARENT(在API级别8和更高版本中将MATCH_PARENT重命名),这意味着该视图的大小必须与父级的大小相同(减去填充) “ from [文档](http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html) – codeMagic

+0

发表评论时请保持正确格式。在上面你没有正确地使粗体 – thinuwan

0

原因是你给match_parent机器人:在第二的LinearLayout layout_height,也没有layout_weight指定相同。由于该水平的LinearLayout正在高度整个屏幕

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/linear1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

<LinearLayout 
android:id="@+id/linear2" 
android:layout_width="match_parent" 
android:layout_height="0dp" 
android:orientation="horizontal" 
android:layout_weight="1"> 

<ImageView 
android:id="@+id/image_profile" 
android:layout_height="48dp" 
android:layout_width="48dp" 
android:layout_marginTop="15dp" 
android:layout_marginLeft="20dp"/> 


<TextView 
android:id="@+id/nom_profile" 
android:layout_width="0dp" 
android:layout_height="wrap_content" 
android:textAppearance="?android:attr/textAppearanceMedium" 
android:layout_weight="1" 
android:layout_marginTop="20dp" 
android:layout_marginLeft="10dp"/> 

<TextView 
android:id="@+id/SocialNetworks" 
android:layout_width="wrap_content" 
android:layout_height="0dp" 
android:text="Redes Sociales" 
android:textAppearance="?android:attr/textAppearanceMedium" 
android:layout_weight="1"/> 


<ListView 
android:id="@+id/listaRedesSociales" 
android:layout_width="fill_parent" 
android:layout_height="0dp" 
android:layout_weight="4"> 
</ListView> 

尝试上面的代码。如果这不能正常工作,请从所有视图中更改(或删除)layout_weight属性(如果删除layout_weight,请记住更改layout_height属性)

相关问题