我有View (RelativeLayout)
,由ScrollView
管理。
该视图包含EditText
。每当EditText
集中注意力时,通过点击或requestFocus()
调用ScrollView
,ScrollView
就会跳回到最高位置。怎样才能使public class MyView extends RelativeLayout{
public MyView(Context context){
super(context);
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int)(4 * 600));
lp.height = (int)(3000);
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
setLayoutParams(lp);
setBackgroundColor(0xddeeeeee);
EditText editText = new EditText(getContext());
editText.setLayoutParams(new ViewGroup.LayoutParams(150, 150));
editText.setX(200);
editText.setY(400);
editText.setBackgroundColor(0xff0000aa);
addView(editText);
}
保持在实际位置?
代码如下:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final LinearLayout listView = (LinearLayout) findViewById(R.id.project_list);
ScrollView scrollView = new ScrollView(getApplicationContext());
MyView view = new MyView(getApplicationContext());
scrollView.addView(view);
listView.addView(scrollView);
}
和活动:
func mapView(_ mapView: MKMapView, clusterAnnotationForMemberAnnotations memberAnnotations: [MKAnnotation]) -> MKClusterAnnotation
答案 0 :(得分:0)
实际上,如果你希望你的整个布局比你应该使用的那样:
<强> SOFT_INPUT_ADJUST_PAN 强>
含义:
getActivity().getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
答案 1 :(得分:0)
android:focusableInTouchMode="true"
android:focusable="true"
将这些行添加到Scroll View中的Relative Layout