<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/keyboard"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:background="#00ff00"
android:text="我是键盘"></TextView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/keyboard"
android:background="#7777ff">
<LinearLayout
android:id="@+id/real_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text1"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#ff0000"
android:text="@string/hello_world" />
<TextView
android:id="@+id/text2"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#ffff00"
android:text="@string/hello_world" />
<TextView
android:id="@+id/text3"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#ff00ff"
android:text="@string/hello_world" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
package com.fish.likeinputmethodeffect;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.content.Intent;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.HashMap;
/**
* 实现类似输入法的效果,点击弹出,再点击收起,用Relativelayout+ScrollView+LinearLayout实现,跟输入法的adjustResize的类似
*/
public class MainActivity extends ActionBarActivity {
private boolean keyboardShow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.real_layout).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
findViewById(R.id.keyboard).setVisibility(keyboardShow?View.GONE:View.VISIBLE);
keyboardShow=!keyboardShow;
}
});
}
}
代码如上,实现类似输入法的效果,点击弹出,再点击收起,用Relativelayout+ScrollView+LinearLayout实现,跟输入法的adjustResize的类似