无法正确放置TextView

时间:2015-11-26 17:10:06

标签: android

任何人都可以帮我将我的标题放在标题下吗? 我对android编程比较新,对不起我的英文不好:D

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

    <ImageView
        android:id="@+id/listIcon"
        android:padding="8dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:src="@drawable/facebook"/>

    <TextView
        android:id="@+id/listText"
        android:layout_gravity="center_vertical"
        android:padding="8dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Title" />

    <TextView
        android:id="@+id/listTextDescription"
        android:layout_gravity="center_vertical"
        android:padding="8dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Undertitle" />


</LinearLayout>

2 个答案:

答案 0 :(得分:0)

试试这个

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

    <ImageView
        android:id="@+id/listIcon"
        android:padding="8dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:src="@drawable/facebook"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:orientation="vertical">

        <TextView
            android:id="@+id/listText"
            android:layout_gravity="center_vertical"
            android:padding="8dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Title" />

        <TextView
            android:id="@+id/listTextDescription"
            android:layout_gravity="center_vertical"
            android:padding="8dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Undertitle" />

    </LinearLayout>

</LinearLayout>

答案 1 :(得分:0)

试试这个,只需将布局从 LinearLayout 更改为 RelativeLayout

$query = $request->get('q');

$explodedQuery = explode(" ", $query);

$articles = Article::isLikeTitle($explodedQuery)
                   ->isLikeBody($explodedQuery)
                   ->latest('published_at')
                   ->published()
                   ->paginate(10);

// Model

public function scopeIsLikeTitle($query, $q)
{
    foreach($q as $eachQueryString)
    {    
        $query->orWhere('title', 'LIKE', '%'.$eachQueryString .'%');
    }
    return $query;
}

public function scopeIsLikeBody($query, $q)
{
    foreach($q as $eachQueryString)
    {    
        $query->orWhere('body', 'LIKE', '%'.$eachQueryString .'%');
    }
    return $query;
}