2014-10-15 3 views
0

나는이 퀴즈를 개발하고 있지만이 문제는이 디자인 ...안드로이드 이클립스는 XML

GuessButton.xml

<?xml version="1.0" encoding="utf-8"?> 
<Button xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/newGuessButton" 
    android:textColor="#FFFFFF" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/buttonshape" 
    android:layout_weight="1" 
    android:shadowColor="#000000" 
    android:shadowDx="5" 
    android:shadowDy="2" 
    android:shadowRadius="5" > 

</Button> 

buttonshape.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > 
<corners 
android:radius="50dp" 
/> 
<gradient 
android:gradientRadius="200" 
android:centerX="35%" 
android:centerY="50%" 
android:centerColor="#5E0707" 
android:startColor="#E80909" 
android:endColor="#000000" 
android:type="radial" 
/> 
<size 
android:height="50dp" 
/> 
<stroke 
android:width="2dp" 
android:color="#878787" 
/> 
</shape> 
버튼이 표시

홈페이지 XML :

<TableLayout 
      android:id="@+id/buttonTableLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:stretchColumns="*" > 

      <TableRow 
       android:id="@+id/tableRow0" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" > 
      </TableRow> 

      <TableRow 
       android:id="@+id/tableRow1" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" > 
      </TableRow> 
     </TableLayout> 

xm L 코드 이미지가 표시되는 위치 : 그들은 자산 폴더에있는 사촌 모든 장치에 맞게 이미지의 경우

<ImageView 
      android:id="@+id/faceImageView" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:adjustViewBounds="false" 
      android:scaleType="centerInside" /> 

.. 나는이 만든 코드 : 제가 테스트 한 모든 장치에 따라서

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.kuizi); 
DisplayMetrics displaymetrics = new DisplayMetrics(); 
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); 
    int width = displaymetrics.widthPixels; 
    int h = faceImageView.getLayoutParams().height; 
    h = width/2; 
    faceImageView.getLayoutParams().height = h; 

을 그것은 잘 작동

: OKAY

하지만 내 친구에

전화는 다음과 같이이다 : ... 여기 screenshoot입니다 그 ... 내가 찾은 일주일에 아무것도 인터넷에서 찾고 있어요 왜

BAD

그래서 작은 이미지와 나쁜 버튼 ... 나는 알아낼 수 없습니다 ... 누군가 pls는 저를 도울 수 ... 미리 감사드립니다 ... 정말 도움을 주시면 고맙겠습니다 ...

+0

기기 정보를 추가해주세요. 각 기기에서 실행중인 Android의 버전은 무엇입니까? –

+0

안드로이드 4.4.2는 안드로이드 4.2.2 및 일부 다른 안드로이드에서 작동하지 않습니다 ... –

답변

0

나는 두 개의 레이아웃을 만들었고 처음에는 이미지로 채우고 두 번째로는 다른 모든 것들을 넣었으므로 이제 화면의 전반부는 그림과 함께 표시되며 후반부는 다른 것들과 함께 표시됩니다. , ...

고마워요 ...

0

전체 레이아웃을 게시하지 않았기 때문에 다소 어렵습니다.하지만이 방법을 시도해보십시오.

RelativeLayout 안에 이미지를 배치하십시오. 이 경우 RelativeLayout은 콘텐츠의 크기를 조정하고 적응해야합니다.

<RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
    > 

<ImageView 
      android:id="@+id/faceImageView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="false" 
      android:scaleType="centerInside" /> 
</RelativeLayout> 

또 다른 해결책은 표를 사용하지 않고 LinearLayout + weight 속성으로 재생할 수 있습니다. 나를 위해, 테이블 작업하기가 더 힘들지만 그것은 당신에게 달린 것입니다!

도움이 되었기를 바랍니다.

관련 문제