Я хочу получить следующий макет в виде списка цитат.макет списка андроидов не в состоянии достичь
я пытаюсь на оранжевом фоне вместо серого и зеленого фона текста вместо белого:
следующее XML-
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="1"
android:stretchMode="columnWidth"
android:gravity="center"
/>
the file quote_text.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/holo_orange_dark" >
<TextView
android:id="@+id/quotetext1"
android:background="@android:color/holo_green_light"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:paddingLeft="20dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:paddingRight="20dp"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:textSize="15dp" >
</TextView>
</LinearLayout>
то, что я получаю следующее
Мой код в GetView() является
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gimkan = inflater.inflate(R.layout.quote_text, parent, false);
textView = (TextView) gimkan.findViewById(R.id.quotetext1);
}
else
{
textView = (TextView) convertView;
}
textView.setText(mThumbIds[position]);
return textView;
}
Я также попытался использовать следующие согласно ответу dieter_h
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:color/holo_orange_dark">
<TextView
android:id="@+id/quotetext1"
android:background="@android:color/holo_green_light"
android:layout_width="match_parent"
android:layout_height="100dp"
tools:text="kfjjkdshf jkhs jkdhs sdjh jksdh s sdjhfjksdh kjsdfh"
android:padding="20dp"
android:layout_margin="15dp"
android:textSize="15dp" />
</LinearLayout>
Все еще это показывает, как необходимо
У вас его есть. Почему мы должны использовать. Во многих местах я не искал его там, где упоминалось –
Возможно, вы захотите использовать маржу для своего списка ListView на первом месте. НО, как и мой опыт, Android не учитывает поля, если в представлении с полями нет родителя, поэтому вы можете либо обернуть ListView с помощью «FrameLayout» (или любых унаследованных классов «ViewGroup», «LinearLayout», «RelativeLayout» ...), но «FrameLayout» - самый легкий в конце, поэтому я выбираю «FrameLayout»), затем установите для него дополнение или не установите дополнение для параметра «FrameLayout», но поля для ListView. Надеюсь, вы это получите;) – Leo