mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-18 22:41:44 +02:00
Set android:tint programatically
as setting it in the xml file triggers an exception on API 19.
This commit is contained in:
@@ -22,6 +22,8 @@ import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -75,6 +77,14 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
statisticsView = inflater.inflate(R.layout.fragment_statistics, container, false);
|
||||
|
||||
// Set android:tint="?attr/editTextColor" programmatically as setting it in xml layout
|
||||
// throws an exception on API 19.
|
||||
int color = new EditText(getContext()).getCurrentTextColor();
|
||||
for (int id : new int[]{R.id.imageGoalWeight, R.id.imageGoalDiff, R.id.imageDayLeft}) {
|
||||
ImageView image = statisticsView.findViewById(id);
|
||||
image.setColorFilter(color);
|
||||
}
|
||||
|
||||
txtGoalWeight = (TextView) statisticsView.findViewById(R.id.txtGoalWeight);
|
||||
txtGoalDiff = (TextView) statisticsView.findViewById(R.id.txtGoalDiff);
|
||||
txtGoalDayLeft = (TextView) statisticsView.findViewById(R.id.txtGoalDayLeft);
|
||||
|
@@ -41,12 +41,11 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView5"
|
||||
android:id="@+id/imageGoalWeight"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_target"
|
||||
android:tint="?attr/editTextColor" />
|
||||
android:src="@drawable/ic_target" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtLabelGoalWeight"
|
||||
@@ -85,12 +84,11 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView6"
|
||||
android:id="@+id/imageGoalDiff"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_difference"
|
||||
android:tint="?attr/editTextColor" />
|
||||
android:src="@drawable/ic_difference" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtLabelGoalDiff"
|
||||
@@ -129,12 +127,11 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView7"
|
||||
android:id="@+id/imageDayLeft"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_daysleft"
|
||||
android:tint="?attr/editTextColor" />
|
||||
android:src="@drawable/ic_daysleft" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtLabelDayLeft"
|
||||
|
Reference in New Issue
Block a user