2016-10-27 3 views
0

나는 Pokémons에 대한 정보를 제공하는 것에 대해 Android 앱을 개발 중입니다.여러 화면 기기에서 Android 앱을 조정하는 방법은 무엇인가요?

그러나 서로 다른 장치간에 전환 할 때 많은 문제가 발생합니다. (당신은 내가 각 장치에 안드로이드 API (23)가 나는 경우)이 스크린 샷 enter image description here

명확 넥서스 5 배에 있지만, 넥서스 5 레이아웃에서 잘 실행되는 응용 프로그램을 볼 수있는

는 총 엉망입니다.

다른 장치의 픽셀 밀도 문제인 Nexus 5에는 xxhdpi 디스플레이가 있고 5X에는 xhdpi와 xxhdpi 사이에 일종의 "하이브리드 디스플레이"가 있습니다. 삼성 Galaxy S6와 Huawei P9 Lite는 동일한 Nexus 5 문제가 있음을 알고 있습니다. drawable-ldpi, drawable-mdpi ... 폴더를 만드는 모든 이미지의 크기를 조정하려고 시도했지만 결과적으로 Android Studio에서 내 그림을 더 이상 볼 수 없었습니다! >. <

정말 어떻게해야할지 모르십니까?

내 레이아웃 XML 파일 :

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/pokedetails" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.thefe.newsmartkedex.MainActivity"> 

<TableLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/pokeImgName"> 
    <TableRow> 
     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/tmppkmn" /> 
    </TableRow> 
    <TableRow> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAlignment="center" 
      android:id="@+id/pkmnName" 
      android:textSize="20sp" 
      android:textStyle="bold" /> 
    </TableRow> 
</TableLayout> 
<TableLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/pokeTypes" 
    android:layout_alignParentEnd="true" 
    android:layout_marginTop="70dp"> 
    <TableRow> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Tipi" 
      android:textAlignment="center" 
      android:textSize="20sp"/> 
    </TableRow> 
    <TableRow> 
     <ImageView 
      android:layout_width="80dp" 
      android:layout_height="26dp" 
      android:id="@+id/tipo1" /> 
    </TableRow> 
    <TableRow> 
     <ImageView 
      android:layout_width="80dp" 
      android:layout_height="26dp" 
      android:id="@+id/tipo2"/> 
    </TableRow> 
    <TableRow android:id="@+id/capturedSwitch"> 
     <Switch 
      android:textStyle="bold|italic" 
      android:layout_gravity="center_horizontal" 
      android:id="@+id/dettagli"/> 
    </TableRow> 
    <TableRow android:id="@+id/capturedButton"> 
     <Button 
      android:textSize="11dp" 
      android:layout_gravity="center_horizontal" 
      android:id="@+id/catturato"/> 
    </TableRow> 
</TableLayout> 

    <TextView 
     android:text="Forte contro" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:layout_alignParentStart="true" 
     android:textSize="20sp" 
     android:id="@+id/forteContro" /> 

    <TableLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/forteContro" 
     android:id="@+id/pokeStrenght"> 

     <TableRow 
      android:padding="10dp"> 
      <ImageView 
       android:layout_width="80dp" 
       android:layout_height="26dp" 
       android:id="@+id/tsf1" 
       android:src="@drawable/veleno"/> 
      <ImageView 
       android:layout_width="80dp" 
       android:layout_height="26dp" 
       android:id="@+id/tsf2" 
       android:src="@drawable/acciaio"/> 
      <ImageView 
       android:layout_width="80dp" 
       android:layout_height="26dp" 
       android:id="@+id/tsf3" 
       android:src="@drawable/fuoco"/> 
      <ImageView 
       android:layout_width="80dp" 
       android:layout_height="26dp" 
       android:id="@+id/tsf4" 
       android:src="@drawable/erba"/> 
     </TableRow> 
    </TableLayout> 

<TextView 
    android:text="Debole contro" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/pokeStrenght" 
    android:textSize="20sp" 
    android:id="@+id/deboleContro" /> 

<TableLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/deboleContro" 
    android:id="@+id/pokeWeakness"> 

    <TableRow 
     android:padding="10dp"> 
     <ImageView 
      android:layout_width="80dp" 
      android:layout_height="26dp" 
      android:id="@+id/tsd1" 
      android:src="@drawable/acqua"/> 
     <ImageView 
      android:layout_width="80dp" 
      android:layout_height="26dp" 
      android:id="@+id/tsd2" 
      android:src="@drawable/psico"/> 
     <ImageView 
      android:layout_width="80dp" 
      android:layout_height="26dp" 
      android:id="@+id/tsd3" 
      android:src="@drawable/lotta"/> 
     <ImageView 
      android:layout_width="80dp" 
      android:layout_height="26dp" 
      android:id="@+id/tsd4" 
      android:src="@drawable/terra"/> 
    </TableRow> 
</TableLayout> 

    <TableLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/pokeWeakness" 
     android:id="@+id/descriptionTable"> 

     <TableRow 
      android:padding="2dp"> 
      <Button 
       android:text="Descrizione" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textSize="11sp" 
       android:layout_gravity="left" 
       android:id="@+id/showhidedescr"/> 
     </TableRow> 
     <TableRow 
      android:padding="2dp"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/descriptiontext" 
       android:textSize="11dp" 
       android:layout_gravity="center_horizontal"> 
      </TextView> 
     </TableRow> 
     <TableRow 
      android:padding="2dp"> 
      <Button 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:text="Leggi\ndescrizione" 
       android:textSize="11sp" 
       android:id="@+id/leggidescrizione" 
       android:layout_gravity="center_horizontal"> 
      </Button> 
     </TableRow> 
    </TableLayout> 

내 자바 파일 :

public class PokemonDetails extends AppCompatActivity implements WebServicesAsyncResponse { 

private TextView tv; 
private TextToSpeech t1; 
private String toSpeech = ""; 

@Override 
public void onCreate (Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.pokedetails); 

    tv = (TextView) findViewById(R.id.descriptiontext); 

    //Prendo i dati Intent 
    Intent i = getIntent(); 

    //Seleziono l'ID del Pokémon che mi servirà per prendere tutti i dati dal database e dai drawable 
    final int pokeID = i.getExtras().getInt("id"); 
    String pokeName = getName(pokeID+1); 

    PokemonDatabaseAdapter pokemonHelper = new PokemonDatabaseAdapter(this); 

    ResponseFromWebService responseFromWebService = new ResponseFromWebService(); 
    WebServicesAsyncResponse ar = this; 
    responseFromWebService.getPokeData(pokeName, ar); 

    ImageAdapter imageAdapter = new ImageAdapter(this); 

    ImageView imageView = (ImageView) findViewById(R.id.tmppkmn); 
    imageView.setImageResource(imageAdapter.mThumbIds[pokeID]); 
    imageView.setContentDescription("Image of the current Pokémon, "+pokeName); 

    imageView = (ImageView) findViewById(R.id.tipo1); 
    imageView.setImageResource(R.drawable.erba); 

    imageView = (ImageView) findViewById(R.id.tipo2); 
    imageView.setImageResource(R.drawable.veleno); 

    TextView pkmnName = (TextView)findViewById(R.id.pkmnName); 
    pkmnName.setText(pokeName); 

    final Switch pokeSwitch = (Switch) findViewById(R.id.dettagli); 
    final Button pokeDetails = (Button) findViewById(R.id.catturato); 

    if (pokemonHelper.getPokemonGO() == 1) { 
     pokeSwitch.setText("Catturato "); 
     pokeDetails.setText("Aggiungi\nDettagli"); 

     //prendendo i dati dal database, pokeDetails dev'essere enabled o disabled 
     pokeDetails.setEnabled(false); 

     pokeSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() { 
      @Override 
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 
       if (pokeSwitch.isChecked()) 
        pokeDetails.setEnabled(true); 
       else 
        pokeDetails.setEnabled(false); 
      } 
     }); 

     pokeDetails.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i = new Intent(getApplicationContext(), MyPokeDetails.class); 
       i.putExtra("id", pokeID); 
       startActivity(i); 
      } 
     }); 
    } 
    else { 
     ViewGroup layout = (ViewGroup) pokeDetails.getParent(); 
     layout.removeView(pokeDetails); 
     layout = (ViewGroup) pokeSwitch.getParent(); 
     layout.removeView(pokeSwitch); 
    } 

    getActionBar(); 

    Button showhide = (Button) findViewById(R.id.showhidedescr); 
    final Button leggi = (Button)findViewById(R.id.leggidescrizione); 
    tv.setVisibility(View.GONE); 
    leggi.setVisibility(View.GONE); 
    showhide.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      if (tv.getVisibility() == View.VISIBLE) { 
       tv.setVisibility(View.GONE); 
       leggi.setVisibility(View.GONE); 
      } 
      else if (tv.getVisibility() == View.GONE) { 
       tv.setVisibility(View.VISIBLE); 
       leggi.setVisibility(View.VISIBLE); 
      } 
     } 
    }); 

    leggi.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      t1=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() { 
       public void onInit(int status) { 
        if(status != TextToSpeech.ERROR) { 
         t1.setLanguage(Locale.ITALIAN); 
         t1.speak(toSpeech, TextToSpeech.QUEUE_FLUSH, null); 
        } 
       } 
      }); 
     } 
    }); 
} 

죄송 codeand 내부의 모든 이탈리아 댓글이 어떤 도움을 주셔서 감사합니다 당신이 날주지!

+0

을 참조하시기 바랍니다이 주제에 대해 더 알고 싶다면 https://www.google.de/search?q=How + 복수 + 화면 + 기기 % 3F & ie = utf-8 & oe = utf-8 & client = firefox-b & gfe_rd = cr & ei = oK8RWMuLMsiF8QeFsbz4CA) 특히 "복수 화면 지원"링크 – 0X0nosugar

+0

당신에게 제안하는 + 화면 크기가 다른 dimen.xml을 사용하십시오. 모범 사례 .. 또는 특정 크기의 새 레이아웃 만들기 – ZeroOne

답변

관련 문제