0
I am trying to get an Activity of a project of mine to contain a considerable amount of Components.
I tried to do this using a Scrollingactivity that contained more than just the "default" textView (the one that comes when it is created), but I found that it is not possible, at least that I know.
My Activity basically contains this model:
But as you can imagine it doesn’t just contain these two questions.
I also tried a Scrollview, but I must not have done the same the right way or simply the same has a limitation of not being able to "exceed" the layout limit.
I would like to know how to put all this in Activity:
With the image I wanted to express that the content I want to add exceeds the same, to the point that I could not use a Scrollview.
I made a code template (only with the first two Buttons, questions and answers) in case it is useful for a better understanding and/or answer:
Mainactivity:
package genesysgeneration.chinterative;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
private Button btnSim01, btnSim02, btnNao01, btnNao02;
private TextView tvPergunta01, tvPergunta02, tvResposta01, tvResposta02;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnSim01=(Button)findViewById(R.id.btnSim01);
btnSim02=(Button)findViewById(R.id.btnSim02);
btnNao01=(Button)findViewById(R.id.btnNao01);
btnNao02=(Button)findViewById(R.id.btnNao02);
tvPergunta01=(TextView)findViewById(R.id.tvPergunta01);
tvPergunta02=(TextView)findViewById(R.id.tvPergunta02);
tvResposta01=(TextView)findViewById(R.id.tvResposta01);
tvResposta02=(TextView)findViewById(R.id.tvResposta02);
}
public void onClick(View v){
switch (v.getId()){
case R.id.btnSim01:
break;
case R.id.btnNao01:
break;
case R.id.btnSim02:
break;
case R.id.btnNao02:
break;
}
}
}
activity_main.xml:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="genesysgeneration.chinterative.MainActivity">
<TextView
android:id="@+id/tvPergunta01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pergunta 1" />
<TextView
android:id="@+id/tvResposta01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/tvPergunta01"
android:layout_marginTop="104dp"
android:text="texto com a resposta baseada na escolha do button " />
<TextView
android:id="@+id/tvPergunta02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:text="pergunta 2" />
<Button
android:id="@+id/btnSim01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/tvPergunta01"
android:layout_marginTop="26dp"
android:text="sim" />
<Button
android:id="@+id/btnNao01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/btnSim01"
android:text="nao" />
<Button
android:id="@+id/btnSim02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/btnSim01"
android:layout_alignRight="@+id/btnSim01"
android:layout_below="@+id/tvPergunta02"
android:layout_marginTop="68dp"
android:text="sim" />
<Button
android:id="@+id/btnNao02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnNao01"
android:layout_alignStart="@+id/btnNao01"
android:layout_alignTop="@+id/btnSim02"
android:text="nao" />
<TextView
android:id="@+id/tvResposta02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/btnSim02"
android:layout_marginTop="46dp"
android:text="texto com a resposta baseada na escolha do button " />
</RelativeLayout>
Put your activity_main in your question.
– viana
you speak of xml?
– Boneco Sinforoso
yes, exactly.
– viana