我目前正在嘗試自己構建一個簡單的聯繫人卡。我只想要一張左上角的個人資料圖片,大約四分之一到三分之一的寬度,右側的名稱+描述。聯繫人卡ui不按預期方式顯示
無論我嘗試什麼,它總是看起來非常類似於下面的截圖。
這是我的佈局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/activity_standard_padding"
android:clipToPadding="false"
android:scrollbarStyle="outsideOverlay"
style="@style/AppBaseThemeCardBG">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/nowCardStyle">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="top"
android:paddingRight="@dimen/activity_horizontal_margin">
<ImageView
android:id="@+id/schuckCard"
android:scaleType="fitCenter"
android:layout_gravity="top"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical">
<com.mikebdev.douala.widget.RobotoTextView
android:id="@+id/schuckHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:typeface="roboto_condensed_light"
android:text="JESCO SCHUCK"
android:textSize="@dimen/textSizeVeryLarge" />
<com.mikebdev.douala.widget.RobotoTextView
android:id="@+id/body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:typeface="roboto_condensed_light"
android:text="Description" />
</LinearLayout>
</LinearLayout>
</ScrollView>
這是它的樣子:
我想圖像約爲一樣寬的操作欄中的說明。顯然我在這裏慘遭失敗
只是一張紙條,你正在使用的卡可拉大到,我也使用這張卡,但有一個類似的使用你現在有。正確地說,卡片應該伸展以適應你的內容,但是卡片很大,並且可繪製的9個貼片不能縮放比原始尺寸小。提示使用Photoshop來縮小尺寸。請改變尺寸,因爲這可能會影響您的陰影質量。相反,通過分割和切割內部部分來縮小圖像。 – TrueCoke
@TrueGuidance感謝tipp,我可能會用不同的9patch或自己做一個。 –