自定义布局中的间距

时间:2015-04-10 15:08:44

标签: android layout spacing

我目前在自定义布局中遇到了一个奇怪的问题。这是一个截图:

enter image description here

这是我的布局文件:

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.fa.sonatic.music"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="350dp">


<de.fa.sonatic.views.LinearLayoutWebBackground
    android:id="@+id/artist_background"
    android:layout_width="fill_parent"
    android:layout_height="350dp"
    android:orientation="vertical">


    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <com.pkmmte.view.CircularImageView
            android:layout_width="175dp"
            android:layout_height="175dp"
            android:id="@+id/imageartist"
            android:scaleType="centerCrop"
            android:layout_centerInParent="true"
            app:border_color="#EEEEEE"
            app:border_width="0dp"
            app:shadow="false" />

        <!--
        <TextView
                android:id="@+id/artist_joindate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:fitsSystemWindows="true"
                android:layout_centerHorizontal="true"
                android:textSize="14sp"
                android:textAllCaps="true"
                android:textColor="#FFFFFF"
                fontPath="SeraSemiBold.ttf"
                android:text=""
                android:textAppearance="?android:attr/textAppearanceSmall"/> -->

        <!--
        <TextView
            android:id="@+id/artist_freetext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:fitsSystemWindows="true"
            android:layout_centerHorizontal="true"
            android:textSize="15sp"
            android:textColor="#FFFFFF"
            fontPath="SeraMedium.ttf"
            android:text=""
            android:textAppearance="?android:attr/textAppearanceLarge"/> -->

        <!--
        <TextView
            android:id="@+id/freetext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:fitsSystemWindows="true"
            android:gravity="center_horizontal|bottom"
            android:textSize="15sp"
            android:textColor="#FFFFFF"
            fontPath="SeraMedium.ttf"
            android:maxLines="1"
            android:visibility="invisible"
            android:text="@string/tagit_taptorecognize"
            android:textAppearance="?android:attr/textAppearanceLarge"/> -->

        <TextView
            android:id="@+id/artist_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:gravity="center_horizontal|bottom"
            android:textSize="22sp"
            android:textColor="#FFFFFF"
            fontPath="SeraMedium.ttf"
            android:maxLines="1"
            android:text="@string/tagit_taptorecognize"
            android:textAppearance="?android:attr/textAppearanceLarge"/>

        <com.example.android.common.filledtabs.view.SlidingTabLayout
            android:id="@+id/sliding_tabs"
            android:layout_below="@id/artist_name"
            android:layout_alignParentBottom="true"
            android:background="@android:color/transparent"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

    </RelativeLayout>



</de.fa.sonatic.views.LinearLayoutWebBackground>

有人知道问题的来源吗?如果我将fill_parent填充到LinearLayoutWebBackground,它将填满整个活动空间。

2 个答案:

答案 0 :(得分:0)

应该这样;

android:layout_below="@id/artist_name"

定;

android:layout_below="@id/imageartist"

或将以上内容添加到textview中?

答案 1 :(得分:0)

尝试:

<?xml version="1.0" encoding="utf-8"?>  
    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.fa.sonatic.music"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="350dp">

    <de.fa.sonatic.views.LinearLayoutWebBackground
    android:id="@+id/artist_background"
    android:layout_width="fill_parent"
    android:layout_height="350dp"
    android:orientation="vertical">


    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <com.pkmmte.view.CircularImageView
            android:layout_width="175dp"
            android:layout_height="175dp"
            android:id="@+id/imageartist"
            android:scaleType="centerCrop"
            android:layout_centerInParent="true"
            app:border_color="#EEEEEE"
            app:border_width="0dp"
            app:shadow="false" />        

        <TextView
            android:id="@+id/artist_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:gravity="center_horizontal|bottom"
            android:textSize="22sp"
            android:layout_above="@id/slidingTabs"
            android:textColor="#FFFFFF"
            fontPath="SeraMedium.ttf"
            android:maxLines="1"
            android:text="@string/tagit_taptorecognize"
            android:textAppearance="?android:attr/textAppearanceLarge"/>

        <com.example.android.common.filledtabs.view.SlidingTabLayout
            android:id="@+id/sliding_tabs"          
            android:layout_alignParentBottom="true"
            android:background="@android:color/transparent"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

    </RelativeLayout>
    </de.fa.sonatic.views.LinearLayoutWebBackground>
    </LinearLayout>