You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Created by iTimeTraveler on 2018/9/14.
*/
public class StrItemView extends BasePickerItemView {
public StrItemView(String data) {
super(data);
this.data = data;
}
@OverRide
public View onCreateView(ViewGroup parent) {
LinearLayout v = new LinearLayout(parent.getContext());
Button b = new Button(parent.getContext());
b.setText("mmm");
AutoFitTextView tv = new AutoFitTextView(parent.getContext());
tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
tv.setPadding(20, 3, 20, 3);
tv.setTextSize(20);
int[] colors = new int[] {PicketOptions.SELECTED_TEXT_COLOR, PicketOptions.DEFAULT_TEXT_COLOR};
int[][] states = {{android.R.attr.state_selected}, {}};
tv.setTextColor(new ColorStateList(states, colors));
tv.setTypeface(ResourcesCompat.getFont(parent.getContext(), R.font.montserrat_medium));
My Main activity
:-
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Arrays;
import java.util.List;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.res.ResourcesCompat;
import io.itimetraveler.widget.adapter.PickerAdapter;
import io.itimetraveler.widget.model.StringItemView;
import io.itimetraveler.widget.picker.PicketOptions;
import io.itimetraveler.widget.picker.WheelPicker;
public class MainActivity extends AppCompatActivity {
public static Context context;
Button button, button2;
WheelPicker mWheelPicker;
String selectedstr = null;
Typeface tf;
View v;
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = this;
v = findViewById(R.id.header_Layout);
button = findViewById(R.id.button);
button2 = findViewById(R.id.button2);
tf = ResourcesCompat.getFont(MainActivity.this, R.font.opensansbold);
mWheelPicker = (WheelPicker) findViewById(R.id.wheel_picker);
final List mList = Arrays.asList("10:10 AM", "10:12 AM", "10:14 AM", "10:16 AM", "10:18 AM", "10:10 AM", "10:12 AM", "10:14 AM", "10:16 AM", "10:18 AM", "10:10 AM", "10:12 AM", "10:14 AM", "10:16 AM", "10:18 AM", "10:10 AM", "10:12 AM", "10:14 AM", "10:16 AM", "10:18 AM", "10:10 AM", "10:12 AM", "10:14 AM", "10:16 AM", "10:18 AM", "10:10 AM", "10:12 AM", "10:14 AM", "10:16 AM", "10:18 AM");
// if (parent.getChildAt(row) instanceof TextView) {
// TextView tab = (TextView) parent.getChildAt(row);
// int tabTypefaceStyle = Typeface.BOLD;
// tab.setTypeface(tf, tabTypefaceStyle);
// tab.setTextColor(Color.parseColor("#123fee"));
// }
return new StrItemView(String.valueOf(str)).onCreateView(parent);
}
// Toast.makeText(MainActivity.context, selectedstr, Toast.LENGTH_LONG).show();
}
stringitemView Class 👎
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import androidx.core.content.res.ResourcesCompat;
import io.itimetraveler.widget.model.BasePickerItemView;
import io.itimetraveler.widget.picker.PicketOptions;
import io.itimetraveler.widget.view.AutoFitTextView;
/**
Created by iTimeTraveler on 2018/9/14.
*/
public class StrItemView extends BasePickerItemView {
public StrItemView(String data) {
super(data);
this.data = data;
}
@OverRide
public View onCreateView(ViewGroup parent) {
LinearLayout v = new LinearLayout(parent.getContext());
Button b = new Button(parent.getContext());
b.setText("mmm");
// tv.setTypeface(ResourcesCompat.getFont(parent.getContext(), R.font.));
tv.setTextColor(new ColorStateList(states, colors));
tv.setText(data, parent.getMeasuredWidth());
return tv;
// tv.setTypeface(ResourcesCompat.getFont(parent.getContext(), R.font.));
tv.setTextColor(new ColorStateList(states, colors));
tv.setText(data, parent.getMeasuredWidth());
}
}
When I changes the tv.setTextSize(20); from 20 to more or less line does not ends up straight
The text was updated successfully, but these errors were encountered: