如何在此图像中创建布局?

时间:2015-12-23 06:12:37

标签: android android-layout listview android-fragments android-activity

我想知道如何在Android中创建此布局?使用相册艺术模糊背景和listView?我需要获取哪些数据?

image

我目前的布局是这样的。 My app layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical"
              android:background="#FF330000"
              tools:context=".MainActivity" >

           <ListView
                     android:id="@+id/song_list"
                     android:layout_width="fill_parent"
                     android:layout_height="wrap_content" >
          </ListView>

   </LinearLayout>

以下Java代码映射歌曲布局

public View getView(int position, View convertView, ViewGroup parent) {
      //map to song layout
      LinearLayout songLay = (LinearLayout)songInf.inflate
  (R.layout.song, parent, false);
     //get title and artist views
     TextView songView = (TextView)songLay.findViewById(R.id.song_title);
     TextView artistView = (TextView)songLay.findViewById(R.id.song_artist);
     //get song using position
     Song currSong = songs.get(position);
      //get title and artist strings
      songView.setText(currSong.getTitle());
      artistView.setText(currSong.getArtist());
     //set position as tag
     songLay.setTag(position);
     return songLay;
    }

1 个答案:

答案 0 :(得分:-1)

不确定这是你想要的。你可以试试。

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="start"
    android:background="@android:color/white"
    android:padding="12dp">

    <ImageView
        android:id="@+id/image"
        android:layout_width="80dp"
        android:layout_height="70dp"
        android:layout_centerVertical="true"
        android:layout_gravity="left"/>

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/image"
        android:layout_centerVertical="true"
        android:paddingLeft="6dp"
        android:orientation="vertical"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true">
        <LinearLayout
            android:id="@+id/ll1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <TextView
                android:id="@+id/name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="18sp"
                android:text="Depeche Mode"
                android:singleLine="true" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/ll2"
            android:layout_below="@+id/ll1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <TextView
                android:id="@+id/type"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="14sp"
                android:textColor="@android:color/secondary_text_dark_nodisable"
                android:text="Remixes 81-04"
                android:maxLines="1"
                android:ellipsize="end" />


        </LinearLayout>

        <LinearLayout
            android:id="@+id/ll3"
            android:layout_below="@+id/ll2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="14sp"
                android:textColor="@android:color/secondary_text_dark_nodisable"
                android:text="12 songs  1:18:53"
                android:maxLines="1"
                android:layout_below="@+id/Amount" />



        </LinearLayout>


    </RelativeLayout>

</RelativeLayout>