Xml文件  |  85行  |  3.9 KB

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<view class="com.android.contacts.editor.PhotoEditorView"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/kind_icon"
        android:src="@drawable/ic_camera_alt_black_24dp"
        android:layout_marginTop="13dp"
        android:contentDescription="@string/header_photo_entry"
        style="@style/EditKindIconStyle" />

    <!-- Needs 10dp of top padding, in order get a total of 32dp of padding between this view
        and the previous DataKindSection. Note that EditTexts in other editor.xml files have this
        padding built in. Similarly, we need to add 4dp of start margin to make up for the padding
        that an EditText would have in this image's place. -->
    <ImageView
        android:id="@+id/photo"
        android:layout_width="72dip"
        android:layout_height="72dip"
        android:cropToPadding="true"
        android:scaleType="centerCrop"
        android:layout_marginTop="15dp"
        android:layout_marginStart="4dp"
        android:contentDescription="@string/description_contact_photo"
        android:layout_marginBottom="@dimen/editor_padding_below_photo"
        android:gravity="start" />

    <!-- We want 16dp for the effective marginStart. So we set 12dp, since the private
        @android:dimen/control_inset_material already includes 4dp of padding. -->
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="12dp" >

        <!-- The values applied to this button are complicated:
            1) We want 16dp internal padding in the button. The background drawable is inset
            by private @android:dimen/button_inset_horizontal_material=4dp. Therefore,
            we need paddingStart/End of 20dp.
            2) In order to leave enough room for the 32dp RadioButton, this can only be 46dp.
            This is 2dp less than the default touch target size.
            3) This button will appear to be offset by the private
            @android:dimen/button_inset_vertical_material amount. Therefore, in order to achieve
            15dp of apparent top margin, we only need to apply 9dp. -->
        <Button
            android:id="@+id/change_button"
            android:layout_width="wrap_content"
            android:layout_height="46dp"
            android:textSize="@dimen/editor_form_text_size"
            android:textColor="@color/primary_text_color"
            android:layout_marginTop="9dp"
            android:paddingStart="20dp"
            android:paddingEnd="20dp"
            android:text="@string/change_photo" />

        <!-- Don't explicitly set the layout_height in case we need to rely on text wrapping.
            For one line, we can expect the height to be 32dp with 16dp text size. -->
        <RadioButton
            android:id="@+id/primary_checkbox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="48dp"
            android:textSize="@dimen/editor_form_text_size"
            android:text="@string/primary_photo" />
    </LinearLayout>
</view>