2017-07-14 55 views
0

我正在开发一个应用笔记本应用程序,我在其中添加图片到笔记中。请查看屏幕截图以及如何滚动gridview和编辑文本。 enter image description here如何在两个edittext中添加gridview在android

enter image description here

enter image description here enter image description here

这是我的XML代码。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.app.pb.privatenotebook.NoteBrief"> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:layout_marginLeft="30dp" 
    android:layout_marginRight="30dp" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_marginTop="15dp" 
    android:id="@+id/linearLayout" 
    android:layout_marginBottom="80dp" 
    > 

    <EditText 
     android:id="@+id/et_sub" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/colorPrimary" 
     android:ems="10" 
     android:hint="Subject" 
     android:textSize="14sp" 
     android:gravity="start" 
     android:maxLines="1" 
     android:inputType="textPersonName" 
     android:padding="10dp" /> 

    <EditText 
     android:id="@+id/et_note" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="5dp" 
     android:ems="10" 
     android:scrollbars="vertical" 
     android:inputType="textMultiLine" 
     android:textSize="16sp" 
     android:padding="10dp" 
     android:gravity="start" 
     android:hint="Note" 
     android:background="@color/colorPrimary" 
     /> 

</LinearLayout> 

<TextView 
    android:id="@+id/tv_cre" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/linearLayout" 
    android:layout_alignParentBottom="true" 
    android:layout_alignStart="@+id/linearLayout" 
    android:layout_marginBottom="54dp" 
    android:text="TextView" /> 
    </RelativeLayout> 

回答

0
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.app.pb.privatenotebook.NoteBrief"> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:layout_marginLeft="30dp" 
    android:layout_marginRight="30dp" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_marginTop="15dp" 
    android:id="@+id/linearLayout" 
    android:layout_marginBottom="80dp" 
    > 

    <EditText 
     android:id="@+id/et_sub" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/colorPrimary" 
     android:ems="10" 
     android:hint="Subject" 
     android:textSize="14sp" 
     android:gravity="start" 
     android:maxLines="1" 
     android:inputType="textPersonName" 
     android:padding="10dp" /> 

<GridView 
    android:id="@+id/gridview" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:columnWidth="90dp" 
    android:numColumns="3" 
    android:verticalSpacing="10dp" 
    android:horizontalSpacing="10dp" 
    android:stretchMode="columnWidth" 
    android:gravity="center" 
/> 

    <EditText 
     android:id="@+id/et_note" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="5dp" 
     android:ems="10" 
     android:scrollbars="vertical" 
     android:inputType="textMultiLine" 
     android:textSize="16sp" 
     android:padding="10dp" 
     android:gravity="start" 
     android:hint="Note" 
     android:background="@color/colorPrimary" 
     /> 

</LinearLayout> 

<TextView 
    android:id="@+id/tv_cre" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/linearLayout" 
    android:layout_alignParentBottom="true" 
    android:layout_alignStart="@+id/linearLayout" 
    android:layout_marginBottom="54dp" 
    android:text="TextView" /> 
    </RelativeLayout> 
+0

感谢答复。我有个问题。你写columnwidth = 1这意味着它们只显示一行中的一个图像。但在图片中,你可以添加最多3图片行 – Dani

+0

雅更改为3像这样,android:numColumns =“3” –

+0

好吧,我会实现你的代码。并告诉你输出 – Dani

相关问题