2014-02-28 28 views
0

我目前正在嘗試自己構建一個簡單的聯繫人卡。我只想要一張左上角的個人資料圖片,大約四分之一到三分之一的寬度,右側的名稱+描述。聯繫人卡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> 

這是它的樣子:

failed cardsui

我想圖像約爲一樣寬的操作欄中的說明。顯然我在這裏慘遭失敗

+0

只是一張紙條,你正在使用的卡可拉大到,我也使用這張卡,但有一個類似的使用你現在有。正確地說,卡片應該伸展以適應你的內容,但是卡片很大,並且可繪製的9個貼片不能縮放比原始尺寸小。提示使用Photoshop來縮小尺寸。請改變尺寸,因爲這可能會影響您的陰影質量。相反,通過分割和切割內部部分來縮小圖像。 – TrueCoke

+0

@TrueGuidance感謝tipp,我可能會用不同的9patch或自己做一個。 –

回答

0

得到了我的固定愚蠢的問題:

ImageView我宣佈android:scaleType="fitCenter"這顯然也是中心在我的佈局中ImageView。 將scaleType更改爲fitStart時,我得到了我想要的結果。

1

使用不同的佈局權重值。就像4圖像和6的內容給它的芯片卡40‰寬度

+0

試了一下,這是一個更好一點...最大的問題是,圖片只是坐在中心,而不是在左上角。 –

相關問題