我有一个垂直有三个图像的图像组,这些组形成一个圆形,我已创建它,因为圆形视图无法调整其宽度以使其成为椭圆形,因为我有三个堆叠的图像一个上面我无法和#39; t将所有这些图像调整为以下代码
static int Standard_height = 160;
static int Cam_Size = 50;
static int Segment_Size = 55;
static int TextSize = 10;
private void SetLayoutDesign() {
Layout_Frame.removeAllViews();
Segments = sharedpreferences.getInt(Vars.Selected_Segment_Count, 4);
int imageGap = Segment_Size + 5;
int size = Segment_Size + ((16 - (Segments + 1)));
int imageSize = Cam_Size - Segments;
for (int i = 0; i < Segments; i++) {
// Create some quick TextViews that can be placed.
String StateName = Vars.Segment_State + "_" + i;
int state = sharedpreferences.getInt(StateName, 0);
String TypeName = Vars.Segment_Type + "_" + i;
int type = sharedpreferences.getInt(TypeName, 0);
Segment_Button[i] = new ImageButton(act);
Segment_Name[i] = new TextView(act);
if (type == 0) {
Segment_Name[i].setText((i + 1) + "");
if (state == 1) {
Segment_Button[i].setBackgroundResource(R.drawable.sort_none);
} else {
Segment_Button[i].setBackgroundResource(R.drawable.sort_off);
}
} else if (type == 1) {
Segment_Name[i].setText((i + 1) + "\nMS");
if (state == 1) {
Segment_Button[i].setBackgroundResource(R.drawable.sort_ms);
} else {
Segment_Button[i].setBackgroundResource(R.drawable.sort_off);
}
} else if (type == 2) {
Segment_Name[i].setText((i + 1) + "\nFR");
if (state == 1) {
Segment_Button[i].setBackgroundResource(R.drawable.sort_fr);
} else {
Segment_Button[i].setBackgroundResource(R.drawable.sort_off);
}
} else if (type == 3) {
Segment_Name[i].setText((i + 1) + "\nSR");
if (state == 1) {
Segment_Button[i].setBackgroundResource(R.drawable.sort_sr);
} else {
Segment_Button[i].setBackgroundResource(R.drawable.sort_off);
}
}
Segment_Name[i].setGravity(Gravity.CENTER);
Segment_Name[i].setTextColor(Color.WHITE);
Segment_Name[i].setTextSize(TextSize);
Segment_Name[i].setId(Segment_Text_Ids[i]);
Segment_Name[i].setTypeface(null, Typeface.BOLD);
Segment_Button[i].setId(Segment_Ids[i]);
FrameLayout.LayoutParams lp1 = new FrameLayout.LayoutParams(imageSize, imageSize);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(size, size);
lp.gravity = Gravity.CENTER;
lp1.gravity = Gravity.CENTER;
Segment_Button[i].setLayoutParams(lp);
Segment_Button[i].setOnClickListener(this);
Segment_Button[i].setOnLongClickListener(this);
Segment_Name[i].setLayoutParams(lp);
float angleDeg = i * 360.0f / Segments - 90.0f;
float angleRad = (float) (angleDeg * Math.PI / 180.0f);
Segment_Button[i].setTranslationX(Standard_height * (float) Math.cos(angleRad));
Segment_Button[i].setTranslationY(Standard_height * (float) Math.sin(angleRad));
Layout_Frame.addView(Segment_Button[i]);
Segment_Name[i].setTranslationX(Standard_height * (float) Math.cos(angleRad));
Segment_Name[i].setTranslationY(Standard_height * (float) Math.sin(angleRad));
if (Segments % 2 == 0 && Segments != 0) {
Segment_Name[i].setRotation((180 / Segments));
} else {
Segment_Name[i].setRotation(0);
}
Layout_Frame.addView(Segment_Name[i]);
FCam_Button[i] = new ImageButton(act);
FCam_Button[i].setId(FCam_Ids[i]);
String FCamName = Vars.FCam_State + "_" + i;
int FCamState = sharedpreferences.getInt(FCamName, 0);
if (FCamState == 0) {
FCam_Button[i].setBackgroundResource(R.drawable.f_camera_off_image);
} else {
FCam_Button[i].setBackgroundResource(R.drawable.f_camera_on_image);
}
FCam_Button[i].setLayoutParams(lp1);
FCam_Button[i].setOnClickListener(this);
FCam_Button[i].setTranslationX((Standard_height + imageGap) * (float) Math.cos(angleRad));
FCam_Button[i].setTranslationY((Standard_height + imageGap) * (float) Math.sin(angleRad));
FCam_Button[i].setRotation(angleDeg + 90.0f);
Layout_Frame.addView(FCam_Button[i]);
RCam_Button[i] = new ImageButton(act);
RCam_Button[i].setId(RCam_Ids[i]);
String RCamName = Vars.RCam_State + "_" + i;
int RCamState = sharedpreferences.getInt(RCamName, 0);
if (RCamState == 0) {
RCam_Button[i].setBackgroundResource(R.drawable.r_camera_off_image);
} else {
RCam_Button[i].setBackgroundResource(R.drawable.r_camera_on_image);
}
RCam_Button[i].setLayoutParams(lp1);
RCam_Button[i].setOnClickListener(this);
RCam_Button[i].setTranslationX((Standard_height - imageGap) * (float) Math.cos(angleRad));
RCam_Button[i].setTranslationY((Standard_height - imageGap) * (float) Math.sin(angleRad));
RCam_Button[i].setRotation(angleDeg + 90.0f);
Layout_Frame.addView(RCam_Button[i]);
}
if (Segments % 2 == 0 && Segments != 0) {
Layout_Frame.setRotation(-(180 / Segments));
} else {
Layout_Frame.setRotation(0);
}
SetUserLevelControls();
}
这是当前的布局
这是所需的布局