텍스트가있는 선을 표시하고 싶지만 45 ° 각도로 수직 또는 수평이되어서는 안됩니다. RelativeLayout에 TextView 및 View (줄에 대한)가 포함되어 있습니다. RelativeLayout.LayoutParams의 도움으로 RelativeLayout의 x/y 위치를 정의하려고합니다. 수평 디스플레이는 이미 작동하지만 45도 각도로 변경하려면 어떻게해야합니까?Android : LinearLayout에서 뷰의 45 ° 각도 (RelativeLayout)를 정의하는 방법
RelativeLayout branch_layout = (RelativeLayout) this
.findViewById(R.id.createrelativelayout);
LinearLayout branch_item = new LinearLayout(this);
branch_item.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
branch_item.setOrientation(1);
TextView tv = new TextView(this);
tv.setLayoutParams(new RelativeLayout.LayoutParams(pos, pos));
tv.setId(id);
tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
tv.setPadding(20, 0, 20, 0);
tv.setText(branch_name);
tv.setOnClickListener(this);
Rect bounds = new Rect();
Paint textPaint = tv.getPaint();
textPaint.getTextBounds(branch_name, 0, branch_name.length(), bounds);
View underline = new View(this);
underline.setLayoutParams(new LayoutParams(bounds.width() + 40, 1));
underline.setBackgroundColor(Color.parseColor("#000000"));
branch_item_layout = new RelativeLayout(this);
branch_item_layout.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Display display = getWindowManager().getDefaultDisplay();
//x
params.leftMargin = display.getWidth()/2;
//y
params.topMargin = ((display.getHeight()/2)-(((LinearLayout) this
.findViewById(R.id.createlinearlayout3)).getWidth()/2)-48);
//end x
params.bottomMargin = params.leftMargin + bounds.width();
//end y
params.rightMargin = (int) (params.leftMargin - (bounds.width()*Math.sin(45)));
branch_item.addView(tv);
branch_item.addView(underline);
branch_item_layout.addView(branch_item, params);
branch_layout.addView(branch_item_layout);
전체 화면 구현은 0-440 는 지금
first x = 400
first y = 114
end x = 434
end y = 371
계획은 45 ° 각도로 함께 문자열 라인을 표시하는 것이 었습니다 Y "풍경"X 0-800위한 것입니다 . 줄의 길이는 문자열 너비를 기준으로합니다. 사람이 딜레마를 도와 줄 수
희망,
사스케 때문에 x와 y 위치의
은 당신의 첫 번째 대답을 편집 ..마다 대답하지 마세요, 당신을 참조하십시오. – SERPRO