我有一個將文件上傳到我的應用程序的對話框活動。問題是,在10個英寸屏幕上的垂直作用,但如果我在一個7英寸的測試寬度只是變得更小(見圖片)寬度對話框活動7英寸
下面是我的代碼因爲我使用了7寸的佈局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Share document wrapper -->
<LinearLayout
android:id="@+id/share_document_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp">
<!-- Document views -->
<TextView
android:id="@+id/share_document_title"
android:text="@string/share_document_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"/>
<!-- Divider -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<!-- /Divider -->
<EditText
android:id="@+id/share_document_single_selected_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:hint="@string/share_document_hint_edittext"/>
<TextView
android:id="@+id/share_document_selected_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:visibility="gone"/>
</LinearLayout>
<!-- Share account wrapper -->
<LinearLayout
android:id="@+id/share_account_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="0dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<!-- Account views -->
<TextView
android:id="@+id/share_account_title"
android:text="@string/share_account_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"/>
<!-- Divider -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<!-- /Divider -->
<LinearLayout
android:id="@+id/share_account_info_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:clickable="true"
android:background="@drawable/sliding_contact_menu_row_selector" >
<TextView
android:id="@+id/share_account_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
<!-- Share project wrapper -->
<LinearLayout
android:id="@+id/share_project_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<!-- Project and folders views -->
<TextView
android:id="@+id/share_project_title"
android:text="@string/share_project_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"/>
<!-- Divider -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<!-- /Divider -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">
<Spinner
android:id="@+id/share_project_spinner"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:spinnerMode="dialog"/>
<Button
android:id="@+id/share_project_create_new_project"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:background="@drawable/green_button"
android:textColor="@color/MyWhite"
android:text="+"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
<!-- Share folder wrapper -->
<LinearLayout
android:id="@+id/share_folder_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<!-- Project and folders views -->
<TextView
android:id="@+id/share_folder_title"
android:text="@string/share_folder_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"/>
<!-- Divider -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<!-- /Divider -->
<LinearLayout
android:id="@+id/share_folder_info_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:clickable="true"
android:background="@drawable/sliding_contact_menu_row_selector" >
<ProgressBar
android:id="@+id/share_loader"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="16dp"
android:layout_gravity="center_vertical" />
<ImageView
android:id="@+id/share_folder_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/folder_icon"
android:layout_marginRight="16dp"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/share_folder_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/share_document_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<!-- Documents views -->
<TextView
android:id="@+id/share_document_title"
android:text="@string/share_document_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"/>
<!-- Divider -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<!-- /Divider -->
<RelativeLayout
android:id="@+id/share_document_info_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingTop="10dp"
android:paddingBottom="30dp"
android:clickable="false"
android:background="@drawable/sliding_contact_menu_row_selector" >
<ImageView
android:id="@+id/share_document_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/upload_document_purple"
android:layout_marginRight="16dp"
android:layout_alignParentLeft="true" />
<TextView
android:id="@+id/share_document_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:layout_toRightOf="@id/share_document_icon"/>
<Switch
android:id="@+id/share_document_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:switchPadding="200sp"
android:thumb="@drawable/switch_custom_share"
android:textOn="Als versie"
android:textOff="Nieuw"
android:textColor="@color/MyWhite"
android:layout_alignParentRight="true"
android:enabled="false"/>
</RelativeLayout>
<TextView
android:id="@+id/share_warning_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/share_warning_message"
android:textColor="@color/MyRed"
android:textSize="14sp"
android:layout_marginBottom="16dp"
android:visibility="gone"/>
</LinearLayout>
<!-- Buttons bottom wrapper -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<LinearLayout
style="?android:attr/buttonBarStyle"
android:id="@+id/share_buttons_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
style="?android:attr/buttonBarButtonStyle"
android:id="@+id/share_button_cancel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/archive_cancel"
android:textSize="20sp"/>
<Button
style="?android:attr/buttonBarButtonStyle"
android:id="@+id/share_button_upload"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="20sp"
android:text="OK"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
因爲我在這裏使用一個自定義的主題是我的自定義樣式:
<style name="MyShareTheme" parent="android:Theme.Holo.Light.Dialog">
<item name="android:windowIsFloating">false</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowSoftInputMode">stateAlwaysHidden</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
問:
我怎樣才能讓7寸屏幕上的對話框活動有大小在10英寸對話框一樣嗎?
編輯:
按照要求,我對我的佈局代碼爲10英寸的屏幕:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Share document wrapper -->
<LinearLayout
android:id="@+id/share_document_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="0dp">
<!-- Document views -->
<TextView
android:id="@+id/share_document_title"
android:text="@string/share_document_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"/>
<!-- Divider -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:background="?android:attr/dividerHorizontal" />
<!-- /Divider -->
<EditText
android:id="@+id/share_document_single_selected_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/share_document_hint_edittext"/>
<TextView
android:id="@+id/share_document_selected_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:textSize="18sp"/>
</LinearLayout>
<!-- Share account wrapper -->
<LinearLayout
android:id="@+id/share_account_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<!-- Account views -->
<TextView
android:id="@+id/share_account_title"
android:text="@string/share_account_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"/>
<!-- Divider -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<!-- /Divider -->
<LinearLayout
android:id="@+id/share_account_info_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:clickable="true"
android:background="@drawable/sliding_contact_menu_row_selector" >
<ImageView
android:id="@+id/share_account_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/person_icon"
android:layout_marginRight="16dp"
android:layout_marginLeft="10dp"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/share_account_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"/>
</LinearLayout>
</LinearLayout>
<!-- Share project wrapper -->
<LinearLayout
android:id="@+id/share_project_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<!-- Project and folders views -->
<TextView
android:id="@+id/share_project_title"
android:text="@string/share_project_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"/>
<!-- Divider -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<!-- /Divider -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">
<Spinner
android:id="@+id/share_project_spinner"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:spinnerMode="dialog"/>
<Button
android:id="@+id/share_project_create_new_project"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:background="@drawable/green_button"
android:textColor="@color/MyWhite"
android:text="+"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
<!-- Share folder wrapper -->
<LinearLayout
android:id="@+id/share_folder_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<!-- Project and folders views -->
<TextView
android:id="@+id/share_folder_title"
android:text="@string/share_folder_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"/>
<!-- Divider -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<!-- /Divider -->
<LinearLayout
android:id="@+id/share_folder_info_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:clickable="true"
android:background="@drawable/sliding_contact_menu_row_selector" >
<ProgressBar
android:id="@+id/share_loader"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="16dp"
android:layout_gravity="center_vertical" />
<ImageView
android:id="@+id/share_folder_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/folder_icon"
android:layout_marginRight="16dp"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/share_folder_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/share_document_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<!-- Documents views -->
<TextView
android:id="@+id/share_document_title"
android:text="@string/share_document_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"/>
<!-- Divider -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<!-- /Divider -->
<RelativeLayout
android:id="@+id/share_document_info_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingTop="10dp"
android:paddingBottom="30dp"
android:clickable="false"
android:background="@drawable/sliding_contact_menu_row_selector" >
<ImageView
android:id="@+id/share_document_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/upload_document_purple"
android:layout_marginRight="16dp"
android:layout_alignParentLeft="true" />
<TextView
android:id="@+id/share_document_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_toRightOf="@id/share_document_icon"/>
<Switch
android:id="@+id/share_document_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:switchPadding="200sp"
android:thumb="@drawable/switch_custom_share"
android:textOn="Als versie"
android:textOff="Nieuw"
android:textColor="@color/MyWhite"
android:layout_alignParentRight="true"
android:enabled="false"/>
</RelativeLayout>
<TextView
android:id="@+id/share_warning_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/share_warning_message"
android:textColor="@color/MyRed"
android:textSize="14sp"
android:layout_marginBottom="16dp"
android:visibility="gone"/>
</LinearLayout>
<!-- Buttons bottom wrapper -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<LinearLayout
style="?android:attr/buttonBarStyle"
android:id="@+id/share_buttons_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
style="?android:attr/buttonBarButtonStyle"
android:id="@+id/share_button_cancel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/archive_cancel"
android:textSize="20sp"/>
<Button
style="?android:attr/buttonBarButtonStyle"
android:id="@+id/share_button_upload"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="20sp"
android:text="OK"/>
</LinearLayout>
</LinearLayout>
是否爲7英寸屏幕設計了單獨的佈局? – GrIsHu
是的,我有一個單獨的7英寸屏幕布局 –
什麼是您保存兩個不同的佈局xmls文件夾的名稱? –