Java Code Examples for android.widget.ScrollView#LayoutParams

The following examples show how to use android.widget.ScrollView#LayoutParams . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InternalSelectionScroll.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ScrollView sv = new ScrollView(this);
    ViewGroup.LayoutParams svLp = new ScrollView.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    LinearLayout ll = new LinearLayout(this);
    ll.setLayoutParams(svLp);
    sv.addView(ll);

    InternalSelectionView isv = new InternalSelectionView(this, 10);
    int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
    LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            2 * screenHeight);  // 2x screen height to ensure scrolling
    isv.setLayoutParams(llLp);
    ll.addView(isv);
    
    setContentView(sv);
}
 
Example 2
Source File: LayoutHelper.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static ScrollView.LayoutParams createScroll(int width, int height, int gravity, float leftMargin, float topMargin, float rightMargin, float bottomMargin) {
    ScrollView.LayoutParams layoutParams = new ScrollView.LayoutParams(getSize(width), getSize(height), gravity);
    layoutParams.leftMargin = AndroidUtilities.dp(leftMargin);
    layoutParams.topMargin = AndroidUtilities.dp(topMargin);
    layoutParams.rightMargin = AndroidUtilities.dp(rightMargin);
    layoutParams.bottomMargin = AndroidUtilities.dp(bottomMargin);
    return layoutParams;
}
 
Example 3
Source File: LayoutHelper.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static ScrollView.LayoutParams createScroll(int width, int height, int gravity, float leftMargin, float topMargin, float rightMargin, float bottomMargin) {
    ScrollView.LayoutParams layoutParams = new ScrollView.LayoutParams(getSize(width), getSize(height), gravity);
    layoutParams.leftMargin = AndroidUtilities.dp(leftMargin);
    layoutParams.topMargin = AndroidUtilities.dp(topMargin);
    layoutParams.rightMargin = AndroidUtilities.dp(rightMargin);
    layoutParams.bottomMargin = AndroidUtilities.dp(bottomMargin);
    return layoutParams;
}
 
Example 4
Source File: LayoutHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static ScrollView.LayoutParams createScroll(int width, int height, int gravity, float leftMargin, float topMargin, float rightMargin, float bottomMargin) {
    ScrollView.LayoutParams layoutParams = new ScrollView.LayoutParams(getSize(width), getSize(height), gravity);
    layoutParams.leftMargin = AndroidUtilities.dp(leftMargin);
    layoutParams.topMargin = AndroidUtilities.dp(topMargin);
    layoutParams.rightMargin = AndroidUtilities.dp(rightMargin);
    layoutParams.bottomMargin = AndroidUtilities.dp(bottomMargin);
    return layoutParams;
}
 
Example 5
Source File: LayoutHelper.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public static ScrollView.LayoutParams createScroll(int width, int height, int gravity, float leftMargin, float topMargin, float rightMargin, float bottomMargin) {
    ScrollView.LayoutParams layoutParams = new ScrollView.LayoutParams(getSize(width), getSize(height), gravity);
    layoutParams.leftMargin = AndroidUtilities.dp(leftMargin);
    layoutParams.topMargin = AndroidUtilities.dp(topMargin);
    layoutParams.rightMargin = AndroidUtilities.dp(rightMargin);
    layoutParams.bottomMargin = AndroidUtilities.dp(bottomMargin);
    return layoutParams;
}
 
Example 6
Source File: LayoutHelper.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public static ScrollView.LayoutParams createScroll(int width, int height, int gravity) {
    return new ScrollView.LayoutParams(getSize(width), getSize(height), gravity);
}
 
Example 7
Source File: LayoutHelper.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public static ScrollView.LayoutParams createScroll(int width, int height, int gravity) {
    return new ScrollView.LayoutParams(getSize(width), getSize(height), gravity);
}
 
Example 8
Source File: LayoutHelper.java    From KrGallery with GNU General Public License v2.0 4 votes vote down vote up
public static FrameLayout.LayoutParams createScroll(int width, int height, int gravity) {
    return new ScrollView.LayoutParams(getSize(width), getSize(height), gravity);
}
 
Example 9
Source File: LayoutHelper.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public static ScrollView.LayoutParams createScroll(int width, int height, int gravity) {
    return new ScrollView.LayoutParams(getSize(width), getSize(height), gravity);
}
 
Example 10
Source File: SingleInputFormActivity.java    From material-singleinputform with MIT License 4 votes vote down vote up
public void setInputGravity(int gravity) {
	ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) innerContainer.getLayoutParams();
	layoutParams.gravity = gravity;
	innerContainer.setLayoutParams(layoutParams);
}
 
Example 11
Source File: SingleInputFormActivity.java    From material-singleinputform with MIT License 4 votes vote down vote up
public int getInputGravity() {
	ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) innerContainer.getLayoutParams();
	return layoutParams.gravity;
}
 
Example 12
Source File: LayoutHelper.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public static ScrollView.LayoutParams createScroll(int width, int height, int gravity) {
    return new ScrollView.LayoutParams(getSize(width), getSize(height), gravity);
}
 
Example 13
Source File: GPictureView.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param noteId                the id of the note this image belows to.
 * @param fragmentDetail        the fragment detail  to use.
 * @param attrs                 attributes.
 * @param requestCode           the code for starting the activity with result.
 * @param parentView            parent
 * @param label                 label
 * @param value                 in case of pictures, the value are the ids of the image, semicolonseparated.
 * @param constraintDescription constraints
 */
public GPictureView(final long noteId, final FormDetailFragment fragmentDetail, AttributeSet attrs, final int requestCode, LinearLayout parentView, String label, String value,
                    String constraintDescription) {
    super(fragmentDetail.getActivity(), attrs);

    _value = value;

    final FragmentActivity activity = fragmentDetail.getActivity();
    LinearLayout textLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 10, 10, 10);
    textLayout.setLayoutParams(layoutParams);
    textLayout.setOrientation(LinearLayout.VERTICAL);
    parentView.addView(textLayout);

    TextView textView = new TextView(activity);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    textView.setPadding(2, 2, 2, 2);
    textView.setText(label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription);
    textView.setTextColor(Compat.getColor(activity, R.color.formcolor));
    textLayout.addView(textView);

    final Button button = new Button(activity);
    StyleHelper.styleButton(activity, button);
    button.setText(R.string.take_picture);
    textLayout.addView(button);

    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
            double[] gpsLocation = PositionUtilities.getGpsLocationFromPreferences(preferences);

            String imageName = ImageUtilities.getCameraImageName(null);
            Intent cameraIntent = new Intent(activity, CameraNoteActivity.class);
            cameraIntent.putExtra(LibraryConstants.PREFS_KEY_CAMERA_IMAGENAME, imageName);
            cameraIntent.putExtra(LibraryConstants.DATABASE_ID, noteId);
            if (gpsLocation != null) {
                cameraIntent.putExtra(LibraryConstants.LATITUDE, gpsLocation[1]);
                cameraIntent.putExtra(LibraryConstants.LONGITUDE, gpsLocation[0]);
                cameraIntent.putExtra(LibraryConstants.ELEVATION, gpsLocation[2]);
            }
            fragmentDetail.startActivityForResult(cameraIntent, requestCode);
        }
    });

    ScrollView scrollView = new ScrollView(activity);
    ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    scrollView.setLayoutParams(scrollLayoutParams);
    parentView.addView(scrollView);

    imageLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    imageLayoutParams.setMargins(10, 10, 10, 10);
    imageLayout.setLayoutParams(imageLayoutParams);
    imageLayout.setOrientation(LinearLayout.HORIZONTAL);
    scrollView.addView(imageLayout);

    try {
        refresh(activity);
    } catch (Exception e) {
        GPLog.error(this, null, e);
    }
}