我正在創建android應用程序。這將動態地產生問題。但基於手機屏幕尺寸視圖並不正確。我不知道如何解決這個問題。我附上了來自不同手機的圖像。 屏幕尺寸-3.7" ,屏幕尺寸-5.0"以編程方式修復Android的屏幕尺寸問題
所有元素的大小是根據畫面size.can任意一個幫助Android的顯示響應屏幕上的變化。
我的代碼...
lView.setBackgroundColor(Color.parseColor("#FFFFFF"));
lView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 220);
GradientDrawable gdtitle = new GradientDrawable();
gdtitle.setCornerRadius(5);
ImageView title = new ImageView(Main2Activity.this);
title.setImageResource(R.drawable.logo);
title.setLayoutParams(layoutParams2);
title.setBackgroundDrawable(gdtitle);
lView.setOrientation(LinearLayout.VERTICAL);
lView.addView(title);
GradientDrawable gd3 = new GradientDrawable();
gd3.setCornerRadius(30);
gd3.setColor(Color.parseColor("#003366"));
gd3.setStroke(0, 0xFF000000);
TextView uname1 = new TextView(Main2Activity.this);
uname1.setText("Hello , "+Sessionname);
uname1.setGravity(Gravity.LEFT);
uname1.setTextColor(Color.parseColor("#003366"));
uname1.setTextSize(20);
uname1.setLayoutParams(l2);
et1 = new TextView(Main2Activity.this);
et1.setHeight(100);
et1.setTextColor(Color.WHITE);
et1.setHintTextColor(Color.WHITE);
et1.setGravity(Gravity.CENTER);
et1.setHint("Select Date");
et1.setBackgroundDrawable(gd3);
et1.setTextSize(15);
et1.setLayoutParams(l2);
lView.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams l4 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
l4.gravity=Gravity.CENTER;
lHorizontalView1.setOrientation(LinearLayout.HORIZONTAL);
lHorizontalView1.setLayoutParams(l4);
lHorizontalView1.addView(uname1);
lHorizontalView1.addView(et1);
lView.addView(lHorizontalView1);