michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko.widget; michael@0: michael@0: import android.content.Context; michael@0: import android.util.AttributeSet; michael@0: import android.view.View; michael@0: import android.widget.LinearLayout.LayoutParams; michael@0: michael@0: public class Divider extends View { michael@0: public static enum Orientation { HORIZONTAL, VERTICAL }; michael@0: michael@0: // Orientation of the divider. michael@0: private Orientation mOrientation; michael@0: michael@0: // Density of the device. michael@0: private int mDensity; michael@0: michael@0: public Divider(Context context, AttributeSet attrs) { michael@0: super(context, attrs); michael@0: michael@0: mDensity = (int) context.getResources().getDisplayMetrics().density; michael@0: michael@0: setOrientation(Orientation.HORIZONTAL); michael@0: } michael@0: michael@0: public void setOrientation(Orientation orientation) { michael@0: if (mOrientation != orientation) { michael@0: mOrientation = orientation; michael@0: michael@0: if (mOrientation == Orientation.HORIZONTAL) michael@0: setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, mDensity)); michael@0: else michael@0: setLayoutParams(new LayoutParams(mDensity, LayoutParams.FILL_PARENT)); michael@0: } michael@0: } michael@0: }