2016-03-22 42 views
-2

Iknow部份懷疑有人問BILLIN次,但沒有一個sulotion我找到犯規幫助我,我有這樣的圓角FragmentDialog

<solid 
    android:color="#FFFFFF"/> 

    <stroke 
     android:width="2dp" 
     android:color="#FFFFFF"/> 
    <corners android:radius="30dp" /> 
</shape> 

形狀加入到我的主RelativeLayout,我佈局文件:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <Button 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:background="@drawable/ic_clear_black_18dp" 
     /> 
    <ImageView 
     android:layout_width="70dp" 
     android:layout_height="70dp" 
     android:layout_centerHorizontal="true" 
     android:id="@+id/dialog_icon" 
     android:src="@drawable/emilypic" 
     android:background="@drawable/cicon" 
     /> 
<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:id="@+id/LLTitleandNick" 
android:layout_below="@id/dialog_icon" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="10dp" 
    > 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/dialog_title" 
     android:textSize="22sp" 
     android:textColor="@color/title_color" 
     android:text="Lily Martinson" 
     /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/dialog_nickname" 
     android:textSize="18sp" 
     android:text="lilmartini" 
     android:layout_marginLeft="35dp" 
    /> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_below="@id/LLTitleandNick" 
android:layout_marginTop="30dp" 
     android:id="@+id/LLFollowers" 
     > 
     <ImageView 
      android:layout_width="20dp" 
      android:layout_height="20dp" 
      android:id="@+id/image_like" 
      android:layout_marginLeft="30dp" 
      android:src="@drawable/ic_favorite_border_black_18dp" 
      /> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/Followers" 
      android:text="Followers" 
      /> 
<ImageView 
    android:layout_width="20dp" 
    android:layout_height="20dp" 
    android:id="@+id/image_follow" 
    android:layout_marginLeft="80dp" 
    android:src="@drawable/ic_directions_walk_black_18dp" 
    /> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Following" 

      /> 
     </LinearLayout> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:id="@+id/LLwithButtons" 
     android:layout_below="@+id/LLFollowers" 
     android:layout_marginTop="70dp" 
     > 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 

      android:background="@drawable/ic_question_answer_black_36dp" 

      /> 
     <Button 
      android:layout_width="60dp" 
      android:layout_height="50dp" 
      android:background="@drawable/cicon" 

      android:layout_marginLeft="35dp" 
      /> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
android:background="@drawable/ic_person_add_black_36dp" 
      android:layout_marginLeft="40dp" 
      /> 


    </LinearLayout> 
</RelativeLayout> 

,但問題是,我需要dialog一些尺寸,我的佈局建立這個dialog但是當我添加shape時,形狀適用於所有屏幕,所有元素都會改變它們的位置,對我來說沒有任何好處。我嘗試更改RelativeLayout(我的主版式)尺寸,但shape仍顯示爲所有screen。如何更改此設置?I試圖添加像(Transculent,對不起,也許錯誤)等一些主題,但沒有任何幫助我。

回答

0

/**去繪製對象夾,只是讓rounded_corner.xml並粘貼下面的代碼,仔細檢查了現在,在您繪製文件夾**/

<?xml version="1.0" encoding="UTF-8"?> 
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <stroke 
     android:width="1dp" 
     android:color="#4D4D4D"/> 

    <corners 
     android:radius="7dp" /> 

    <padding 
     android:left="1dp" 
     android:right="1dp" 
     android:top="1dp" 
     android:bottom="1dp"/> 

    <solid android:color="#FFF"/> 

</shape> 

/**創建或不是這個XML去你的layout.xml複製並粘貼此代碼**/

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:background="@drawable/rounded_corner"> 
<Button 
android:layout_width="40dp" 
android:layout_height="40dp" 
android:background="@drawable/ic_clear_black_18dp" 
    /> 
<ImageView 
android:layout_width="70dp" 
android:layout_height="70dp" 
android:layout_centerHorizontal="true" 
android:id="@+id/dialog_icon" 
android:src="@drawable/emilypic" 
android:background="@drawable/cicon" 
    /> 
<LinearLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:id="@+id/LLTitleandNick" 
android:layout_below="@id/dialog_icon" 
android:layout_centerHorizontal="true" 
android:layout_marginTop="10dp" 
    > 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/dialog_title" 
    android:textSize="22sp" 
    android:textColor="@color/title_color" 
    android:text="Lily Martinson" 
    /> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/dialog_nickname" 
    android:textSize="18sp" 
    android:text="lilmartini" 
    android:layout_marginLeft="35dp" 
    /> 
</LinearLayout> 
<LinearLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="horizontal" 
android:layout_below="@id/LLTitleandNick" 
android:layout_marginTop="30dp" 
android:id="@+id/LLFollowers" 
    > 
<ImageView 
    android:layout_width="20dp" 
    android:layout_height="20dp" 
    android:id="@+id/image_like" 
    android:layout_marginLeft="30dp" 
    android:src="@drawable/ic_favorite_border_black_18dp" 
    /> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/Followers" 
    android:text="Followers" 
    /> 
<ImageView 
    android:layout_width="20dp" 
    android:layout_height="20dp" 
    android:id="@+id/image_follow" 
    android:layout_marginLeft="80dp" 
    android:src="@drawable/ic_directions_walk_black_18dp" 
    /> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Following" 

    /> 
</LinearLayout> 
<LinearLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="horizontal" 
android:id="@+id/LLwithButtons" 
android:layout_below="@+id/LLFollowers" 
android:layout_marginTop="70dp" 
    > 
<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 

    android:background="@drawable/ic_question_answer_black_36dp" 

    /> 
<Button 
    android:layout_width="60dp" 
    android:layout_height="50dp" 
    android:background="@drawable/cicon" 

    android:layout_marginLeft="35dp" 
    /> 
<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/ic_person_add_black_36dp" 
    android:layout_marginLeft="40dp" 
    /> 
</LinearLayout> </RelativeLayout> 
+0

採用Android:layout_gravity =「中心」在父相對佈局也,這樣就可以在屏幕 –

+0

中間看到此佈局,請停止添加多個答案。一個就足夠了。要麼編輯較舊的那個,要麼用較新的一個替換舊的。 –

+0

我不知道有什麼問題,但角落不會改變 – Rost