android.widget.LinearLayout#requestLayout ( )源码实例Demo

下面列出了android.widget.LinearLayout#requestLayout ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MidiSheetMusic-Android   文件: MidiPlayer.java
/** The callback for pausing playback.
 *  If we're currently playing, pause the music.
 *  The actual pause is done when the timer is invoked.
 */
public void Pause() {
    this.setVisibility(View.VISIBLE);
    LinearLayout layout = (LinearLayout)this.getParent();
    layout.requestLayout();
    this.requestLayout();
    this.invalidate();

    if (midifile == null || sheet == null || numberTracks() == 0) {
        return;
    }

    // Cancel pending play events
    timer.removeCallbacks(DoPlay);

    if (playstate == playing) {
        playstate = initPause;
    }
    else if (playstate == midi) {
        playstate = paused;
    }
}
 
源代码2 项目: onpc   文件: MonitorFragment.java
private void updateListeningModeLayout()
{
    listeningModeLayout.requestLayout();
    if (listeningModeLayout.getChildCount() == 1)
    {
        final LinearLayout l = (LinearLayout) listeningModeLayout.getChildAt(0);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        if (l.getMeasuredWidth() < listeningModeLayout.getMeasuredWidth())
        {
            params.gravity = Gravity.CENTER;
        }
        l.setLayoutParams(params);
        l.requestLayout();
    }
}
 
源代码3 项目: nearby-android   文件: MapActivity.java
/**
 * Show the list of directions
 * @param directions List of DirectionManeuver items containing navigation directions
 */
public final void showDirections(final List<DirectionManeuver> directions){
  final FragmentManager fm = getSupportFragmentManager();
  RouteDirectionsFragment routeDirectionsFragment = (RouteDirectionsFragment) fm.findFragmentById(R.id.route_directions_container);
  if (routeDirectionsFragment == null){
    routeDirectionsFragment = RouteDirectionsFragment.newInstance();
    ActivityUtils.addFragmentToActivity(
        getSupportFragmentManager(), routeDirectionsFragment, R.id.route_directions_container, getString(R.string.route_fragment));
  }
  // Show the fragment
  final LinearLayout layout = findViewById(R.id.route_directions_container);
  layout.setLayoutParams(new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
      ViewGroup.LayoutParams.MATCH_PARENT));
  layout.requestLayout();

  // Hide the map
  final FrameLayout mapLayout = findViewById(R.id.map_fragment_container);
  final CoordinatorLayout.LayoutParams  layoutParams  =  new CoordinatorLayout.LayoutParams(0,0);
  layoutParams.setMargins(0, 0,0,0);
  mapLayout.setLayoutParams(layoutParams);
  mapLayout.requestLayout();

  routeDirectionsFragment.setRoutingDirections(directions);
}
 
源代码4 项目: nearby-android   文件: MapActivity.java
/**
 * Restore map to original size and remove
 * views associated with displaying route segments.
 * @return MapFragment - The fragment containing the map
 */
public final MapFragment restoreMapAndRemoveRouteDetail(){
  // Remove the route directions
  final LinearLayout layout = findViewById(R.id.route_directions_container);
  layout.setLayoutParams(new CoordinatorLayout.LayoutParams(0, 0));
  layout.requestLayout();

  // Show the map
  final FrameLayout mapLayout = findViewById(R.id.map_fragment_container);

  final CoordinatorLayout.LayoutParams  layoutParams  =  new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
      ViewGroup.LayoutParams.MATCH_PARENT);
  mapLayout.setLayoutParams(layoutParams);
  mapLayout.requestLayout();

  final FragmentManager fm = getSupportFragmentManager();
  final MapFragment mapFragment = (MapFragment) fm.findFragmentById(R.id.map_fragment_container);
  mapFragment.removeRouteDetail();
  return mapFragment;
}
 
private void updateUIForOrientation() {
    final LinearLayout playerContainer = getView().findViewById(R.id.player_container);
    final int orientation = getResources().getConfiguration().orientation;
    if (playerContainer != null) {
        final DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            float screenHeight = displayMetrics.heightPixels;
            playerContainer.setLayoutParams(new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT, (int) screenHeight));
            setFullScreen(true);
        } else {
            float screenWidth = displayMetrics.widthPixels;
            float ideaHeight = screenWidth * 9 / 16;
            playerContainer.setLayoutParams(new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT, (int) ideaHeight));
            setFullScreen(false);
        }
        playerContainer.requestLayout();
    }
    updateUI(orientation);
}
 
源代码6 项目: nearby-android   文件: MapActivity.java
/**
 * Display the specific directions for the segment of the route
 * the user has clicked on.
 * @param position An integer representing the index in the
 *                 list of segment directions.
 */
public final void showRouteDetail(final int position){
  // Hide the list of directions
  final LinearLayout layout = findViewById(R.id.route_directions_container);
  layout.setLayoutParams(new CoordinatorLayout.LayoutParams(0,0));
  layout.requestLayout();

  // Restore the map, removing any route segment detail
  final MapFragment  mapFragment = restoreMapAndRemoveRouteDetail();
  // Add specific route segment detail
  mapFragment.showRouteDetail(position);
}
 
protected void fillTabControls(
        LinearLayout layout,
        Bundle savedState,
        JSONArray elements)
        throws JSONException {

    Cursor featureCursor = getFeatureCursor();
    List<Field> fields = mLayer.getFields();
    for (int i = 0; i < elements.length(); i++) {
        IFormControl control;
        JSONObject element = elements.getJSONObject(i);
        String type = element.optString(JSON_TYPE_KEY);
        if (type.equals(JSON_COORDINATES_VALUE)) {
            JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY);
            String fieldY = attributes.optString(JSON_FIELD_NAME_KEY + "_lat");
            attributes.put(JSON_FIELD_NAME_KEY, fieldY);
            element.put(JSON_TYPE_KEY, type + "_lat");
            control = getControl(this, element, mLayer, mFeatureId, mGeometry, mIsViewOnly);
            addToLayout(control, element, fields, savedState, featureCursor, layout);

            attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY);
            String fieldX = attributes.optString(JSON_FIELD_NAME_KEY + "_long");
            attributes.put(JSON_FIELD_NAME_KEY, fieldX);
            element.put(JSON_TYPE_KEY, type + "_lon");
        }

        control = getControl(this, element, mLayer, mFeatureId, mGeometry, mIsViewOnly);
        if (type.equals(JSON_TABS_KEY))
            ((Tabs) control).init(mLayer, mFeatureId, mGeometry, mTable, mRow, mSharedPreferences,
                                  mPreferences, getSupportFragmentManager(), mIsViewOnly);

        addToLayout(control, element, fields, savedState, featureCursor, layout);
    }

    if (null != featureCursor) {
        featureCursor.close();
    }

    layout.requestLayout();
}