我有一个页面,它只显示一堆数据并有几个按钮。它几乎是静态的。我想通过让页面能够移动来使页面感觉更灵敏。我知道在考虑一页数据时我经常只是向上滚动。
我以为我会用滚动视图围绕我的页面,但这使得屏幕底部有一个小的空白条(好像它正在包装内容,但我将它设置为填充父项)。
无论如何,这是我的xml:
<ScrollView
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"
tools:context=".DealerDetails">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ababab">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff"
android:layout_marginLeft="15dp"
android:layout_gravity="center_vertical"
android:text="Store" />
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#ffffff"
android:layout_marginLeft="30dp"
android:layout_gravity="center_vertical"
android:text="2 mi." />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginLeft="15dp">
<ImageView
android:id="@+id/DirectionsImage"
android:layout_weight="1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:contentDescription="@string/CD_Dealer_Location"
android:src="@drawable/device_access_location_found"
android:layout_marginRight="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical">
<TextView
android:id="@+id/address1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b91af"
android:text="555 Super St. Suite 500" />
<TextView
android:id="@+id/address2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b91af"
android:text="San Antonio, TX 78791" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="3dp"
android:layout_marginLeft="15dp">
<ImageView
android:id="@+id/PhoneImage"
android:layout_weight="1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:contentDescription="@string/CD_Dealer_Phone_Number"
android:src="@drawable/device_access_call"
android:layout_marginRight="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_vertical">
<TextView
android:id="@+id/address1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:layout_marginRight="10dp"
android:text="Sales: " />
<TextView
android:id="@+id/address1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b91af"
android:text="830-626-5200" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_vertical">
<TextView
android:id="@+id/address1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:layout_marginRight="10dp"
android:text="Service: " />
<TextView
android:id="@+id/address1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b91af"
android:text="830-661-4511" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="3dp"
android:layout_marginLeft="15dp">
<ImageView
android:id="@+id/HoursImage"
android:layout_weight="1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:contentDescription="@string/CD_Dealer_Hours_Of_Operation"
android:src="@drawable/device_access_time"
android:layout_marginRight="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical">
<TextView
android:id="@+id/ServiceHoursHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:layout_marginBottom="1dp"
android:text="Service Hours" />
<TextView
android:id="@+id/ServiceHoursDetails1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#232323"
android:layout_marginLeft="12dp"
android:text="Monday-Friday: 8:00 AM - 8:00 PM" />
<TextView
android:id="@+id/ServiceHoursDetails2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#232323"
android:layout_marginLeft="12dp"
android:text="Saturday: 8:00 AM - 5:00 PM" />
<TextView
android:id="@+id/ServiceHoursDetails3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#232323"
android:layout_marginLeft="12dp"
android:text="Sunday: CLOSED" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="3dp"
android:layout_marginLeft="15dp">
<ImageView
android:id="@+id/HoursImage"
android:layout_weight="1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:contentDescription="@string/CD_Dealer_Hours_Of_Operation"
android:src="@drawable/device_access_time"
android:layout_marginRight="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical">
<TextView
android:id="@+id/SalesHoursHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:layout_marginBottom="1dp"
android:text="Sales Hours" />
<TextView
android:id="@+id/SalesHoursDetails1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#232323"
android:layout_marginLeft="12dp"
android:text="Monday-Friday: 8:00 AM - 6:00 PM" />
<TextView
android:id="@+id/SalesHoursDetails2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#232323"
android:layout_marginLeft="12dp"
android:text="Saturday: 8:00 AM - 3:00 PM" />
<TextView
android:id="@+id/SalesHoursDetails3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#232323"
android:layout_marginLeft="12dp"
android:text="Sunday: CLOSED" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="3dp"
android:layout_marginLeft="15dp">
<ImageView
android:id="@+id/ServicesImage"
android:layout_weight="1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:contentDescription="@string/CD_Dealer_Services_Offered"
android:src="@drawable/gear"
android:layout_marginRight="15dp" />
<LinearLayout
android:layout_width="241dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="@+id/ServiceHoursHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:layout_marginBottom="2dp"
android:text="Services" />
<TextView
android:id="@+id/ServiceHoursDetails1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:text="Body Shop, New Heavy Duty, Used Heavy Sales, Service"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#232323" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/MyLocationButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:background="@drawable/dark_button"
android:padding="5dp"
android:text="@string/view_inventory"
android:textColor="#FFFFFF"
android:onClick="viewInventory" />
</LinearLayout>
</ScrollView>
对大块文本感到抱歉,但重要的部分可能只是最外面的两个元素。