在上面的代码中,中间的日历实际上是一个gridview。正如你所看到的那样,它并没有覆盖整个空间,并且有一个可见的黑色背景。如何拉伸列或行,以便不存在黑色空间。
gridview的xml如下:
<GridView android:id="@+id/calendar"
android:numColumns="7"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</GridView>
提前谢谢。
编辑: 更新两个
日历右侧仍有一些空格。如何将其删除?
编辑: 更新3
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_above="@id/menuoptions">
<RelativeLayout style="@style/widescreen"
android:background="@drawable/top_header">
<ImageView style="@style/compactview" android:src="@drawable/banner1"
android:layout_marginLeft="5dip" android:id="@+id/bannerview"
android:layout_centerVertical="true"></ImageView>
<ImageView style="@style/compactview" android:src="@drawable/logo"
android:layout_marginRight="20dip" android:layout_alignParentRight="true"></ImageView>
</RelativeLayout>
<LinearLayout style="@style/widescreen"
android:background="#ffffff" android:orientation="vertical">
<LinearLayout style="@style/widescreen"
android:background="#ffffff" android:orientation="horizontal">
<Button style="@style/compactview" android:background="@drawable/kalenderhover"
android:layout_marginLeft="3dip" android:onClick="calendarButtonClicked"
android:id="@+id/calendarbutton" android:layout_marginTop="6dip"
android:layout_marginBottom="5dip"></Button>
<Button style="@style/compactview" android:background="@drawable/tag"
android:onClick="dayButtonClicked" android:id="@+id/daybutton"
android:layout_marginTop="6dip" android:layout_marginBottom="5dip"></Button>
<Button style="@style/compactview" android:background="@drawable/monat"
android:id="@+id/monthbutton" android:onClick="monthButtonClicked"
android:layout_marginTop="6dip" android:layout_marginBottom="5dip"></Button>
<Button style="@style/compactview" android:background="@drawable/jahr"
android:id="@+id/yearbutton" android:onClick="yearButtonClicked"
android:layout_marginTop="6dip" android:layout_marginBottom="5dip"></Button>
<Spinner style="@style/compactview" android:id="@+id/category_name"
android:background="@drawable/categoriahover"
android:layout_marginLeft="5dip" android:layout_marginTop="7dip"
android:layout_marginBottom="4dip"></Spinner>
</LinearLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="@drawable/calenderheaderwithoutarrow"
android:id="@+id/calendarheader">
<ImageView android:id="@+id/prevMonth" android:src="@drawable/left_arrow"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dip" android:layout_marginTop="5dip">
</ImageView>
<Button android:id="@+id/currentMonth" android:layout_weight="0.6"
android:textColor="#FFFFFF" android:textAppearance="?android:attr/textAppearanceMedium"
android:background="@android:color/transparent"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</Button>
<ImageView android:layout_marginRight="10dip" android:id="@+id/nextMonth"
android:src="@drawable/right_arrow" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_marginTop="5dip">
</ImageView>
</LinearLayout>
<ViewFlipper android:id="@+id/mainflipper" style="@style/compactview">
<LinearLayout android:id="@+id/calendartab" style="@style/compactview"
android:orientation="vertical">
<GridView android:id="@+id/calendar" android:numColumns="7"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:listSelector="@drawable/datecell"
android:layout_marginRight="0dip" android:paddingRight="0dip">
</GridView>
<ListView android:id="@+id/eventlist" style="@style/widescreen">
</ListView>
</LinearLayout>
<LinearLayout android:id="@+id/daytab" style="@style/compactview"
android:orientation="vertical">
<LinearLayout style="@style/compactview"
android:background="@drawable/calenderheader">
<EditText style="@style/compactview" android:id="@+id/searchkeyword"
android:hint="Suche" android:inputType="text"
android:layout_marginLeft="5dip" android:minWidth="200dip">
</EditText>
<Button android:onClick="searchingButtonClicked"
android:background="@drawable/abbrechen"
android:layout_marginLeft="5dip" style="@style/compactview"
android:layout_gravity="center_vertical|right"></Button>
</LinearLayout>
<ListView android:id="@+id/daylisting" style="@style/compactview"></ListView>
</LinearLayout>
<LinearLayout android:id="@+id/monthtab" style="@style/compactview"
android:orientation="vertical">
<LinearLayout style="@style/compactview"
android:background="@drawable/calenderheader">
<EditText style="@style/compactview" android:id="@+id/searchkeyword"
android:hint="Suche" android:inputType="text"
android:layout_marginLeft="5dip" android:minWidth="200dip">
</EditText>
<Button android:onClick="searchingButtonClicked"
android:background="@drawable/abbrechen"
android:layout_marginLeft="5dip" style="@style/compactview"
android:layout_gravity="center_vertical|right"></Button>
</LinearLayout>
<ListView android:id="@+id/monthlisting" style="@style/compactview"></ListView>
</LinearLayout>
<LinearLayout android:id="@+id/yeartab" style="@style/compactview"
android:orientation="vertical">
<LinearLayout style="@style/compactview"
android:background="@drawable/calenderheader">
<EditText style="@style/compactview" android:id="@+id/searchkeyword"
android:hint="Suche" android:inputType="text"
android:layout_marginLeft="5dip" android:minWidth="200dip">
</EditText>
<Button android:onClick="searchingButtonClicked"
android:background="@drawable/abbrechen"
android:layout_marginLeft="5dip" style="@style/compactview"
android:layout_gravity="center_vertical|right"></Button>
</LinearLayout>
<ListView android:id="@+id/yearlisting" style="@style/compactview"></ListView>
</LinearLayout>
</ViewFlipper>
</LinearLayout>
</RelativeLayout>
精简视图的宽度和高度设置为wrap_content
答案 0 :(得分:0)
请参阅this answer的 Update2 部分 @Shekhar遇到了同样的问题,在那次更新中你可以找到
我希望你能解决它!
<强>更新强>:
您可能还想为strechMode
指定GridView
,以使列在父布局中平均延伸:
<GridView [...] android:stretchMode="columnWidth" />