androidx.appcompat.widget.LinearLayoutCompat Java Examples

The following examples show how to use androidx.appcompat.widget.LinearLayoutCompat. 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: ThemeView.java    From SAI with GNU General Public License v3.0 6 votes vote down vote up
private void init() {
    LinearLayoutCompat container = new LinearLayoutCompat(getContext());
    container.setOrientation(LinearLayoutCompat.VERTICAL);
    MaterialCardView.LayoutParams containerLayoutParams = new MaterialCardView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    containerLayoutParams.gravity = Gravity.CENTER;
    addView(container, containerLayoutParams);

    mThemeTitle = new AppCompatTextView(getContext());
    mThemeTitle.setGravity(Gravity.CENTER);
    mThemeTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    LinearLayoutCompat.LayoutParams titleLayoutParams = new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    container.addView(mThemeTitle, titleLayoutParams);

    mThemeMessage = new AppCompatTextView(getContext());
    mThemeMessage.setGravity(Gravity.CENTER);
    mThemeMessage.setVisibility(GONE);
    LinearLayoutCompat.LayoutParams messageLayoutParams = new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    container.addView(mThemeMessage, messageLayoutParams);
}
 
Example #2
Source File: MainActivity.java    From Detect-Resolution with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@SuppressLint("SetTextI18n")
@Override
protected void onResume() {
    super.onResume();

    DisplayCapabilities dc = new DisplayCapabilities(this);

    setContentView(R.layout.activity_main);

    // Use Dual Screen Layout if is on a Surface Duo.
    if (dc.isAppSpanned()) {
        if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            setContentView(R.layout.activity_main_horizontal_dual_screen);
        }
        if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            setContentView(R.layout.activity_main_vertical_dual_screen);
        }
    }

    // Initializing View
    LinearLayoutCompat bg = findViewById(R.id.background);
    LinearLayoutCompat horizontalGap = findViewById(R.id.horizontalGap);
    TextView model = findViewById(R.id.idModel);
    TextView resolution = findViewById(R.id.idResolution);
    TextView dimensions = findViewById(R.id.idDemensions);
    TextView density = findViewById(R.id.idDesity);
    TextView isHDR = findViewById(R.id.idIsHDR);
    TextView isWideColor = findViewById(R.id.isWideColor);
    TextView refreshRate = findViewById(R.id.refreshRate);

    // Set Display Information
    model.setText(dc.getModelNumber());
    resolution.setText(dc.getResolutionsInPixels() + dc.getSupportedResolutions());
    dimensions.setText(dc.getDimensionsInDp());
    density.setText(dc.getScaleFactor() + "x");
    isHDR.setText(dc.getHdrCapabilities());
    isWideColor.setText(dc.getWideColorSupport());
    refreshRate.setText(dc.getRefreshRate() + dc.getSupportedRefreshRates());

}
 
Example #3
Source File: MapFragment.java    From nearby-android with Apache License 2.0 4 votes vote down vote up
/**
 * Populate the place detail contained
 * within the bottom sheet
 * @param place - Place item selected by user
 */
@Override public final void showDetail(final Place place) {
  final TextView txtName = mBottomSheet.findViewById(R.id.placeName);
  txtName.setText(place.getName());
  String address = place.getAddress();
  final String[] splitStrs = TextUtils.split(address, ",");
  if (splitStrs.length>0)                                   {
    address = splitStrs[0];
  }
  final TextView txtAddress = mBottomSheet.findViewById(R.id.placeAddress);
  txtAddress.setText(address);
  final TextView txtPhone  = mBottomSheet.findViewById(R.id.placePhone);
  txtPhone.setText(place.getPhone());

  final LinearLayout linkLayout = mBottomSheet.findViewById(R.id.linkLayout);
  // Hide the link placeholder if no link is found
  if (place.getURL().isEmpty()) {
    linkLayout.setLayoutParams(new LinearLayoutCompat.LayoutParams(0, 0));
    linkLayout.requestLayout();
  }else {
    final int height = (int) (48 * Resources.getSystem().getDisplayMetrics().density);
    linkLayout.setLayoutParams(new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
        height));
    linkLayout.requestLayout();
    final TextView txtUrl = mBottomSheet.findViewById(R.id.placeUrl);
    txtUrl.setText(place.getURL());
  }


  final TextView txtType = mBottomSheet.findViewById(R.id.placeType);
  txtType.setText(place.getType());

  // Assign the appropriate icon
  final Drawable d =   CategoryHelper.getDrawableForPlace(place, getActivity()) ;
  txtType.setCompoundDrawablesWithIntrinsicBounds(d,null,null,null);
  mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);

  // Center map on selected place
  mPresenter.centerOnPlace(place);
  mShowSnackbar = false;
  mCenteredPlaceName = place.getName();
}