Android屏幕适配和文字屏幕适配
http://blog.sina.com.cn/s/blog_9996c67e0101euwd.html
<xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/ergetiandi_back1" > android:id="@+id/rel_title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" > android:id="@+id/er_ge_tian_di" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="60dip" android:layout_marginTop="80dip" android:background="@drawable/select_go_back_press" /> android:id="@+id/upper_paper" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="620dip" android:layout_marginTop="50dip" android:background="@drawable/select_pager_up_press" /> android:id="@+id/next_paper" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="620dip" android:layout_marginTop="50dip" android:background="@drawable/select_pager_down_press" /> android:id="@+id/song" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="160dip" android:layout_marginTop="160dip" android:background="@drawable/select_song_press" /> android:id="@+id/accompany" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/song" android:layout_marginLeft="21dp" android:layout_toRightOf="@+id/song" android:background="@drawable/select_accompany_press" /> android:id="@+id/gridView1" android:layout_width="fill_parent" android:layout_height="450dip" android:layout_below="@+id/rel_title" android:layout_marginTop="60dip" android:numColumns="5" >
<xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/ergetiandi_back1" > android:id="@+id/rel_title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" > android:id="@+id/er_ge_tian_di" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="60dip" android:layout_marginTop="80dip" android:background="@drawable/select_go_back_press" /> android:id="@+id/upper_paper" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="620dip" android:layout_marginTop="50dip" android:background="@drawable/select_pager_up_press" /> android:id="@+id/next_paper" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="620dip" android:layout_marginTop="50dip" android:background="@drawable/select_pager_down_press" /> android:id="@+id/song" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="160dip" android:layout_marginTop="160dip" android:background="@drawable/select_song_press" /> android:id="@+id/accompany" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/song" android:layout_marginLeft="21dp" android:layout_toRightOf="@+id/song" android:background="@drawable/select_accompany_press" /> android:id="@+id/gridView1" android:layout_width="fill_parent" android:layout_height="450dip" android:layout_below="@+id/rel_title" android:layout_marginTop="60dip" android:numColumns="5" >
private void getFindViews() { upper_paper = (Button) findViewById(R.id.upper_paper); next_paper = (Button) findViewById(R.id.next_paper); btnBack = (Button) this.findViewById(R.id.er_ge_tian_di); btnSong = (Button) this.findViewById(R.id.song); btnAccompany = (Button) this.findViewById(R.id.accompany); RelativeLayout.LayoutParams er_ge_tian_diParams = new RelativeLayout.LayoutParams((int) (60 * Config.WITH_RATE), (int) (60 * Config.HEIGHT_RATE)); er_ge_tian_diParams.leftMargin = (int)(60 * Config.WITH_RATE); er_ge_tian_diParams.topMargin = (int)(80 * Config.HEIGHT_RATE); btnBack.setLayoutParams(er_ge_tian_diParams); RelativeLayout.LayoutParams next_paperParams=new RelativeLayout.LayoutParams((int) (130 * Config.WITH_RATE), (int) (55 * Config.HEIGHT_RATE)); next_paperParams.leftMargin=(int)(620 * Config.WITH_RATE); next_paperParams.topMargin=(int)(50 * Config.HEIGHT_RATE); next_paper.setLayoutParams(next_paperParams); RelativeLayout.LayoutParams upper_paperParams=new RelativeLayout.LayoutParams((int) (130 * Config.WITH_RATE), (int) (55 * Config.HEIGHT_RATE)); upper_paperParams.leftMargin=(int)(620 * Config.WITH_RATE); upper_paperParams.topMargin=(int)(50 * Config.HEIGHT_RATE); upper_paper.setLayoutParams(upper_paperParams); RelativeLayout.LayoutParams songParams=new RelativeLayout.LayoutParams((int) (60 * Config.WITH_RATE), (int) (30 * Config.HEIGHT_RATE)); songParams.leftMargin=(int)(160 * Config.WITH_RATE); songParams.topMargin=(int)(160 * Config.HEIGHT_RATE); btnSong.setLayoutParams(songParams); RelativeLayout.LayoutParams accompanyParams=new RelativeLayout.LayoutParams((int) (60 * Config.WITH_RATE), (int) (30 * Config.HEIGHT_RATE)); accompanyParams.leftMargin=(int)(21 * Config.WITH_RATE); accompanyParams.addRule(RelativeLayout.RIGHT_OF, R.id.song); accompanyParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.song); btnAccompany.setLayoutParams(accompanyParams); RelativeLayout.LayoutParams gridView1Params=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, (int) (450 * Config.HEIGHT_RATE)); gridView1Params.topMargin=(int)(60 * Config.HEIGHT_RATE); gridView1Params.addRule(RelativeLayout.BELOW, R.id.rel_title); mGridView.setLayoutParams(gridView1Params);
private void getFindViews() { upper_paper = (Button) findViewById(R.id.upper_paper); next_paper = (Button) findViewById(R.id.next_paper); btnBack = (Button) this.findViewById(R.id.er_ge_tian_di); btnSong = (Button) this.findViewById(R.id.song); btnAccompany = (Button) this.findViewById(R.id.accompany); RelativeLayout.LayoutParams er_ge_tian_diParams = new RelativeLayout.LayoutParams((int) (60 * Config.WITH_RATE), (int) (60 * Config.HEIGHT_RATE)); er_ge_tian_diParams.leftMargin = (int)(60 * Config.WITH_RATE); er_ge_tian_diParams.topMargin = (int)(80 * Config.HEIGHT_RATE); btnBack.setLayoutParams(er_ge_tian_diParams); RelativeLayout.LayoutParams next_paperParams=new RelativeLayout.LayoutParams((int) (130 * Config.WITH_RATE), (int) (55 * Config.HEIGHT_RATE)); next_paperParams.leftMargin=(int)(620 * Config.WITH_RATE); next_paperParams.topMargin=(int)(50 * Config.HEIGHT_RATE); next_paper.setLayoutParams(next_paperParams); RelativeLayout.LayoutParams upper_paperParams=new RelativeLayout.LayoutParams((int) (130 * Config.WITH_RATE), (int) (55 * Config.HEIGHT_RATE)); upper_paperParams.leftMargin=(int)(620 * Config.WITH_RATE); upper_paperParams.topMargin=(int)(50 * Config.HEIGHT_RATE); upper_paper.setLayoutParams(upper_paperParams); RelativeLayout.LayoutParams songParams=new RelativeLayout.LayoutParams((int) (60 * Config.WITH_RATE), (int) (30 * Config.HEIGHT_RATE)); songParams.leftMargin=(int)(160 * Config.WITH_RATE); songParams.topMargin=(int)(160 * Config.HEIGHT_RATE); btnSong.setLayoutParams(songParams); RelativeLayout.LayoutParams accompanyParams=new RelativeLayout.LayoutParams((int) (60 * Config.WITH_RATE), (int) (30 * Config.HEIGHT_RATE)); accompanyParams.leftMargin=(int)(21 * Config.WITH_RATE); accompanyParams.addRule(RelativeLayout.RIGHT_OF, R.id.song); accompanyParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.song); btnAccompany.setLayoutParams(accompanyParams); RelativeLayout.LayoutParams gridView1Params=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, (int) (450 * Config.HEIGHT_RATE)); gridView1Params.topMargin=(int)(60 * Config.HEIGHT_RATE); gridView1Params.addRule(RelativeLayout.BELOW, R.id.rel_title); mGridView.setLayoutParams(gridView1Params);
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。