Skip to content

Instantly share code, notes, and snippets.

View ZieIony's full-sized avatar

ZieIony

View GitHub Profile
<resources>
<style name="carbon_Theme.Light" parent="Theme.MaterialComponents.Light">
<item name="carbon_imageViewStyle">@style/carbon_ImageView</item>
</style>
</resources>
<resources>
<style name="carbon_ImageView">
<item name="carbon_rippleColor">@null</item>
<item name="carbon_rippleHotspot">false</item>
<item name="android:menu">@menu/main</item>
</style>
// extend the default style of the view's parent class if there is one
<style name="carbon_Button" parent="@android:style/Widget.Button"/>
</resources>
<resources>
// style reference for use in themes
<attr name="carbon_imageViewStyle" format="reference"/>
</resources>
<resources>
// declaration
<attr name="carbon_rippleColor" format="color"/>
<declare-styleable name="ImageView">
// usage
<attr name="carbon_rippleColor"/>
// declaration and usage in one line
<attr name="carbon_rippleHotspot" format="boolean"/>
<layout>
<TextView
android:layout_width="120dp"
android:layout_height="32dp"
guide_htmlText="Select Dates"
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="@style/TextAppearance.Body1" />
</layout>
<LinearLayout>
<ImageView
style="@style/ImageView.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_airplanemode_on_24px" />
</LinearLayout>
public class Button extends android.widget.Button{
public Button(Context context) {
super(context);
initButton(null, android.R.attr.buttonStyle, R.style.carbon_Button);
}
public Button(Context context, AttributeSet attrs) {
super(context, attrs);
initButton(attrs, android.R.attr.buttonStyle, R.style.guide_Button);
open class RadioButton : TextView, Checkable {
constructor(context: Context)
: super(context, null, android.R.attr.radioButtonStyle) {
initRadioButton(null, android.R.attr.radioButtonStyle, R.style.guide_RadioButton)
}
constructor(context: Context, attrs: AttributeSet)
: super(context, attrs, android.R.attr.radioButtonStyle) {
initRadioButton(attrs, android.R.attr.radioButtonStyle, R.style.guide_RadioButton)
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int)
public class TextView extends android.widget.TextView {
public TextView(Context context) {
super(context);
initTextView(null, android.R.attr.textViewStyle);
}
public TextView(Context context, String text) {
super(context);
initTextView(null, android.R.attr.textViewStyle);
setText(text);
}
open class RadioButton : TextView, Checkable {
@JvmOverloads
constructor(context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = android.R.attr.radioButtonStyle,
defStyleRes: Int = R.style.guide_RadioButton)
: super(context, attrs, defStyleAttr, defStyleRes) {
initRadioButton(attrs, defStyleAttr, defStyleRes)
}
fun initRadioButton(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) {