할일 앱과 비슷합니다. xml 파일에 의해 설정되는 최상위 막대가 있으며 런타임에 바로 아래에있는 일부 textviews를 만들고 싶습니다. 또한 클릭 할 때 새로운 텍스트보기를 추가하는 버튼이 있습니다.Android 장소보기 동적 상대보기
버튼에서 새로운 textview를 만들면 어떻게 새 Textview가 내가 만든 정적 textviews 및/또는 레이아웃 아래에 있는지 확인해야합니까? 지금은 그렇지 않습니다. 단지 겹쳐서입니다.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_main);
Button btn = (Button) findViewById(R.id.Add_new);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AddNewTask(v);
}
});
}
난 그냥 overalpp 새로운 텍스트 뷰와 둘 다 추가 옵션을 모두 시도 및 I/아래, 내가 찾을 수있는 대부분의 최고 단지 하차있는 등 아래 등의 방법에있는 모든 문서를 찾아 아래 정보를 정렬 할 수 없습니다 이는 내 XML
public void AddNewTask(View v) {
RelativeLayout rl = (RelativeLayout) findViewById(R.id.overallview);
TextView tv= new TextView(this);
tv.setText("TEST");
rl.addView(tv);
}
이 경우에는 유용하지 않을 것
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/overallview"
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.robertli.hustle.MainActivity"
tools:showIn="@layout/activity_main"
android:background="#00095e">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:id="@+id/topbar"
>
<TextView
android:id="@+id/app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
android:text="Hustle"
android:textSize="25dp" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:layout_below="@id/topbar"
android:id="@+id/Add_new"
android:background="#00095e"
android:textColor="#ffffff"
android:clickable="true"
android:textSize="50dp" />
이 링크 확인 - https://stackoverflow.com/questions/2305395/how-to-lay-out-views-in-relativelay 프로그램 외적으로? rq = 1 –